BÁO CÁO

1. CODE PROC F1 ĐỂ ENTER CHI TIẾT

// Some code
dynamic f = Cls_Common_Functions.GetAOpenForm("FOR0024");
DataView dv = f.dg.DataSource as DataView;

string colName = "";
string cmm = "";
int thang = 0, nam = 0;
// Lấy tên cột đang click 
colName = dv.Table.Columns[f.dg.CurrentCell.ColumnIndex].ColumnName;

// lấy điều kiện ngày ở giao diện xem báo cáo
string tro = "_thu_tien.ngay_thc>='"+ Cls_VariGlobal.MdiParentForm.p_ngay_thc1 + "' and _thu_tien.ngay_thc<='" + Cls_VariGlobal.MdiParentForm.p_ngay_thc2 + "'";

// lấy điều kiện id bophan,khoanmuc trên báo cáo, dòng đang click		
string bophan = f.dg.CurrentRow.Cells["bophan"].Value.ToString().Trim();
string khoanmuc = f.dg.CurrentRow.Cells["khoanmuc"].Value.ToString().Trim();

if(colName.StartsWith("thang_"))
		{
	thang = Convert.ToInt32(colName.Split('_')[1].ToString());
	nam = Convert.ToInt32(colName.Split('_')[2].ToString());
			cmm = @"
	Select distinct _thu_tien.* 
	from _thu_tien  
	INNER JOIN _tkhoan ON _tkhoan.ma = _thu_tien.ma_tk0 or _tkhoan.ma = _thu_tien.ma_tk1 
	where _thu_tien.dvcs=1 and _thu_tien.loaidl IN(0) 
	and (left(_thu_tien.ma_tk0,3)<>'911' and left(_thu_tien.ma_tk1,3)<>'911') 
	and ((Select _tkhoan.ma) like N'6%' or (Select _tkhoan.ma) like N'811%') and (_thu_tien.ma_tk0<'N') 
	and _thu_tien.bo_phan=" + bophan + @"
	and _thu_tien.khoanmuc=" + khoanmuc + @"
	and (_thu_tien.ngay_thc>= '" + new DateTime(nam,thang, 01).ToString("MM/dd/yyyy")+"'"+ @" and _thu_tien.ngay_thc<= '"+ new DateTime(nam,thang, 01).AddMonths(1).AddDays(-1).ToString("MM/dd/yyyy") +@"')
	Order by _thu_tien.ngay_thc
	";
		
	}		
	else
		
	{	
	cmm = @"
		Select distinct _thu_tien.* 
		from _thu_tien  
		INNER JOIN _tkhoan ON _tkhoan.ma = _thu_tien.ma_tk0 or _tkhoan.ma = _thu_tien.ma_tk1 
		where _thu_tien.dvcs=1 and _thu_tien.loaidl IN(0) 
		and (left(_thu_tien.ma_tk0,3)<>'911' and left(_thu_tien.ma_tk1,3)<>'911') 
		and ((Select _tkhoan.ma) like N'6%' or (Select _tkhoan.ma) like N'811%') and (_thu_tien.ma_tk0<'N') 
		and _thu_tien.bo_phan=" + bophan + @"
		and _thu_tien.khoanmuc=" + khoanmuc + @"
		and " + tro + @"
		Order by _thu_tien.ngay_thc
		";
		}
//Cls_Common_Functions.EditCode(cmm);
	

// select thành bảng dữ liệu. và view dữ liệu lên
DataTable dt = Cls_Common_Functions.SQLSelect(cmm);
string[] btnlist = { "F12", "F4", "F5", "F3", "Ctrl_F3", "Ctrl_I", "F8", "F7", "F6", "F2", "F1", "F10", "F9", "Freeze", "Ctrl_P" };
this.AddATable("_thu_tien", dt);
Cls_Common_Functions.FormFit(dt, "", "", "f_identity", "Dữ liệu tìm thấy ", true, false, btnlist, false, false);

Last updated