/// <summary> /// Load lai thong so phieu, matu truc... khi biet duoc id cua d_xtutrucll /// </summary> /// <param name="aIDXuatTutruc"></param> private void f_get_thongtinphieu(decimal aIDXuatTutruc) { string asql = "select 'xxx' as mmyy, to_char(a.ngay,'dd/mm/yyyy') as ngay, a.loai, a.phieu, a.nhom, a.makp, a.makhoa "; asql += " from xxx.d_duyet a inner join xxx.d_xtutrucll b on a.id=b.idduyet where b.id<>0 and b.id=" + aIDXuatTutruc; DataSet ads = new DataSet(); ads = d.get_data_mmyy(asql, s_ngay, d.ngayhienhanh_server.Substring(0, 10), true); if (ads != null && ads.Tables.Count > 0 && ads.Tables[0].Rows.Count > 0) { string tmp_mmyy = ""; foreach (DataRow dr in ads.Tables[0].Rows) { ngay.Value = d.StringToDate(dr["ngay"].ToString()); tmp_mmyy = dr["mmyy"].ToString().Replace(user, ""); mm.Value = decimal.Parse(tmp_mmyy.Substring(0, 2)); yyyy.Value = decimal.Parse(tmp_mmyy.Substring(2, 2)) + 2000; chkAll.Checked = true; nhom.SelectedValue = dr["nhom"].ToString(); nhom_SelectedIndexChanged(null, null); makp.SelectedValue = dr["makhoa"].ToString(); makp_SelectedIndexChanged(null, null); matutruc.SelectedValue = dr["makp"].ToString(); phieu.SelectedValue = dr["phieu"].ToString(); //ena_obj(false); break; } } else { ena_obj(true); } }
private bool kiemtra(bool list) { s_loaint = ""; s_tenloai = ""; for (int i = 0; i < loai.Items.Count; i++) { if (loai.GetItemChecked(i)) { s_loaint += dtloai.Rows[i]["id"].ToString() + ","; s_tenloai += dtloai.Rows[i]["ten"].ToString().Trim() + ","; } } s_mabn = ""; foreach (DataRow r in dsmabn.Tables[0].Select("chon=true", "mabn")) { s_mabn += "'" + r["mabn"].ToString().Trim() + "',"; } DateTime dt1 = d.StringToDate(tu.Text).AddDays(-d.iNgaykiemke); DateTime dt2 = d.StringToDate(den.Text).AddDays(d.iNgaykiemke); int y1 = dt1.Year, m1 = dt1.Month; int y2 = dt2.Year, m2 = dt2.Month; int itu, iden; string mmyy = ""; ds.Clear(); for (int i = y1; i <= y2; i++) { itu = (i == y1)?m1:1; iden = (i == y2)?m2:12; for (int j = itu; j <= iden; j++) { mmyy = j.ToString().PadLeft(2, '0') + i.ToString().Substring(2, 2); if (d.bMmyy(mmyy)) { get_xuat(mmyy, list); } } } if (!list) { if (ds.Tables[0].Rows.Count == 0) { MessageBox.Show(lan.Change_language_MessageText("Không có số liệu !"), d.Msg); return(false); } } return(true); }
private decimal sotien(decimal maql, string tu, string den) { DateTime dt1 = d.StringToDate(tu).AddDays(-d.iNgaykiemke); DateTime dt2 = d.StringToDate(den).AddDays(d.iNgaykiemke); int y1 = dt1.Year, m1 = dt1.Month; int y2 = dt2.Year, m2 = dt2.Month; int itu, iden; string mmyy = ""; decimal sotien = 0; DataTable dt; for (int i = y1; i <= y2; i++) { itu = (i == y1)?m1:1; iden = (i == y2)?m2:12; for (int j = itu; j <= iden; j++) { mmyy = j.ToString().PadLeft(2, '0') + i.ToString().Substring(2, 2); if (d.bMmyy(mmyy)) { dt = d.get_data("select sum(sotien) sotien from " + user + mmyy + ".d_tienthuoc where maql=" + maql + " and to_date(ngay,'dd/mm/yy') between to_date('" + tu.Substring(0, 10) + "','dd/mm/yy') and to_date('" + den.Substring(0, 10) + "','dd/mm/yy')").Tables[0]; if (dt.Rows[0]["sotien"].ToString() != "") { sotien += decimal.Parse(dt.Rows[0]["sotien"].ToString()); } } } /*if (v.bYy(i.ToString().Substring(2,2))) * { * dt=v.get_data("select sum(soluong*(dongia+vattu)) sotien from v_vpkhoa where maql="+maql+" and to_date(ngay,'dd/mm/yy') between to_date('"+tu.Substring(0,10)+"','dd/mm/yy') and to_date('"+den.Substring(0,10)+"','dd/mm/yy')").Tables[0]; * if (dt.Rows[0]["sotien"].ToString()!="") sotien+=decimal.Parse(dt.Rows[0]["sotien"].ToString()); * }*/ } return(sotien); }
private bool kiemtra() { bSothe = int.Parse(m.sothe(int.Parse(madoituong.SelectedValue.ToString())).Substring(0, 2)) > 0; if (tu.Value > den.Value) { MessageBox.Show( lan.Change_language_MessageText("Ngày/tháng không hợp lệ !"), d.Msg); tu.Focus(); return(false); } s_kho = ""; if (kho.CheckedItems.Count == 0) { for (int i = 0; i < kho.Items.Count; i++) { kho.SetItemCheckState(i, CheckState.Checked); } } for (int i = 0; i < kho.Items.Count; i++) { if (kho.GetItemChecked(i)) { s_kho += dtdmkho.Rows[i]["id"].ToString() + ","; } } Tao_nhom(); Tao_dataset(); // DateTime dt1 = d.StringToDate(tu.Text).AddDays(-d.iNgaykiemke); DateTime dt2 = d.StringToDate(den.Text).AddDays(d.iNgaykiemke); int y1 = dt1.Year, m1 = dt1.Month; int y2 = dt2.Year, m2 = dt2.Month; int itu, iden; string mmyy = ""; for (int i = y1; i <= y2; i++) { itu = (i == y1)?m1:1; iden = (i == y2)?m2:12; for (int j = itu; j <= iden; j++) { mmyy = j.ToString().PadLeft(2, '0') + i.ToString().Substring(2, 2); if (d.bMmyy(mmyy)) { get_xuat(mmyy); } } } if (ds.Tables[0].Rows.Count == 0) { MessageBox.Show( lan.Change_language_MessageText("Không có số liệu !"), d.Msg); return(false); } i_cot = 0; dsxml.Merge(ds.Tables[0].Select("true", "stt,sothe1,sothe2,sothe3,sothe,ngayvao,sotoa,mabn")); dsxml.Tables[0].Columns.Remove("STT"); dsxml.Tables[0].Columns.Remove("SOTHE1"); dsxml.Tables[0].Columns.Remove("SOTHE2"); dsxml.Tables[0].Columns.Remove("SOTHE3"); dsxml.Tables[0].Columns.Remove("ID"); dsxml.Tables[0].Columns.Remove("NGAYVAO"); dsxml.Tables[0].Columns.Remove("SONGAY"); dsxml.Tables[0].Columns.Remove("SOLUOT"); dsxml.Tables[0].Columns.Remove("DIACHI"); dsxml.Tables[0].Columns.Remove("NGAYSINH"); i_cot = 7; return(true); }
private void tao_table() { ds = new DataSet(); ds.ReadXml("..\\..\\..\\xml\\d_xuat_ct.xml"); dskp = new DataSet(); dskp.ReadXml("..\\..\\..\\xml\\d_xuat_ct.xml"); DateTime dt1 = d.StringToDate(tu.Text).AddDays(-d.iNgaykiemke); DateTime dt2 = d.StringToDate(den.Text).AddDays(d.iNgaykiemke); int y1 = dt1.Year, m1 = dt1.Month; int y2 = dt2.Year, m2 = dt2.Month; int itu, iden; DataRow r1, r2; for (int i = y1; i <= y2; i++) { itu = (i == y1)?m1:1; iden = (i == y2)?m2:12; for (int j = itu; j <= iden; j++) { s_mmyy = j.ToString().PadLeft(2, '0') + i.ToString().Substring(2, 2); if (d.bMmyy(s_mmyy)) { xxx = user + s_mmyy; sql = "select distinct a.makp,c.ten from " + xxx + ".d_xuatsdll a," + xxx + ".d_thucxuat b," + user + ".d_duockp c where a.id=b.id and a.makp=c.id"; sql += " and a.ngay between to_date('" + tu.Text + "'," + stime + ") and to_date('" + den.Text + "'," + stime + ")"; sql += " and a.loai<>3 and a.nhom=" + i_nhom; if (s_kho != "") { sql += " and b.makho in (" + s_kho.Substring(0, s_kho.Length - 1) + ")"; } sql += " union all "; sql += "select distinct a.makp,c.ten from " + xxx + ".d_xuatsdll a," + xxx + ".d_thucbucstt b," + user + ".d_duockp c where a.id=b.id and a.makp=c.id"; sql += " and a.ngay between to_date('" + tu.Text + "'," + stime + ") and to_date('" + den.Text + "'," + stime + ")"; sql += " and a.loai=2 and a.nhom=" + i_nhom; if (s_kho != "") { sql += " and b.makho in (" + s_kho.Substring(0, s_kho.Length - 1) + ")"; } foreach (DataRow r in d.get_data(sql).Tables[0].Rows) { r1 = d.getrowbyid(dskp.Tables[0], "mabd=" + int.Parse(r["makp"].ToString())); if (r1 == null) { r2 = dskp.Tables[0].NewRow(); r2["mabd"] = r["makp"].ToString(); r2["ma"] = r["ten"].ToString(); dskp.Tables[0].Rows.Add(r2); } } } } } dc = new DataColumn(); dc.ColumnName = "hoantra"; dc.DataType = Type.GetType("System.Decimal"); ds.Tables[0].Columns.Add(dc); dc = new DataColumn(); dc.ColumnName = "ngoaitru"; dc.DataType = Type.GetType("System.Decimal"); ds.Tables[0].Columns.Add(dc); dc = new DataColumn(); dc.ColumnName = "treem"; dc.DataType = Type.GetType("System.Decimal"); ds.Tables[0].Columns.Add(dc); dc = new DataColumn(); dc.ColumnName = "khac"; dc.DataType = Type.GetType("System.Decimal"); ds.Tables[0].Columns.Add(dc); dc = new DataColumn(); dc.ColumnName = "noitru"; dc.DataType = Type.GetType("System.Decimal"); ds.Tables[0].Columns.Add(dc); foreach (DataRow r in dskp.Tables[0].Select("true", "mabd")) { dc = new DataColumn(); dc.ColumnName = "sl_" + r["mabd"].ToString().PadLeft(3, '0'); dc.DataType = Type.GetType("System.Decimal"); ds.Tables[0].Columns.Add(dc); } dc = new DataColumn(); dc.ColumnName = "tongcong"; dc.DataType = Type.GetType("System.Decimal"); ds.Tables[0].Columns.Add(dc); }
private void Tao_dataset() { ds = new DataSet(); ds.ReadXml("..//..//..//xml//d_bcngay.xml"); dsngay.Clear(); DateTime dt1 = d.StringToDate(tu.Text); DateTime dt2 = d.StringToDate(den.Text); int y1 = dt1.Year, m1 = dt1.Month; int y2 = dt2.Year, m2 = dt2.Month; int itu, iden; string mmyy = ""; for (int i = y1; i <= y2; i++) { itu = (i == y1)?m1:1; iden = (i == y2)?m2:12; for (int j = itu; j <= iden; j++) { mmyy = j.ToString().PadLeft(2, '0') + i.ToString().Substring(2, 2); xxx = user + mmyy; if (dieutri.SelectedIndex == 0) { sql = "select distinct to_char(a.ngay,'yymmdd') as ngay,to_char(a.ngay,'dd/mm') as ten from " + xxx + ".d_xuatsdll a," + xxx + ".d_xuatsdct b," + user + ".d_dmbd c "; sql += " where a.id=b.id and b.mabd=c.id and a.nhom=" + i_nhom + " and a.ngay between to_date('" + tu.Text + "'," + stime + ") and to_date('" + den.Text + "'," + stime + ")"; if (s_manhom != "") { sql += " and c.manhom in (" + s_manhom.Substring(0, s_manhom.Length - 1) + ")"; } sql += " and a.makhoa=" + int.Parse(makp.SelectedValue.ToString()); } else { sql = "select distinct to_char(a.ngay,'yymmdd') as ngay,to_char(a.ngay,'dd/mm') as ten from " + xxx + ".bhytkb a," + xxx + ".bhytthuoc b," + user + ".d_dmbd c," + user + ".d_duockp d"; sql += " where a.id=b.id and b.mabd=c.id and a.makp=d.makp and a.nhom=" + i_nhom + " and a.ngay between to_date('" + tu.Text + "'," + stime + ") and to_date('" + den.Text + "'," + stime + ")"; sql += " and a.loaiba=2"; if (s_manhom != "") { sql += " and c.manhom in (" + s_manhom.Substring(0, s_manhom.Length - 1) + ")"; } sql += " and d.id=" + int.Parse(makp.SelectedValue.ToString()); } dr = d.get_data(sql).Tables[0].Select("ngay<>''", "ngay"); for (int k = 0; k < dr.Length; k++) { r1 = d.getrowbyid(dsngay.Tables[0], "ngay='" + dr[k]["ngay"].ToString() + "'"); if (r1 == null) { r2 = dsngay.Tables[0].NewRow(); r2["ngay"] = dr[k]["ngay"].ToString(); r2["ten"] = dr[k]["ten"].ToString(); dsngay.Tables[0].Rows.Add(r2); dc = new DataColumn(); dc.ColumnName = "SL_" + dr[k]["ngay"].ToString().Trim(); dc.DataType = Type.GetType("System.Decimal"); ds.Tables[0].Columns.Add(dc); } } } } dc = new DataColumn(); dc.ColumnName = "TONGCONG"; dc.DataType = Type.GetType("System.Decimal"); ds.Tables[0].Columns.Add(dc); }
private void taotable() { if (!kiemtra()) { return; } i_dongia = d.d_dongia_le(int.Parse(nhom.SelectedValue.ToString())); ds.Clear(); s_loai = ""; s_phieu = ""; for (int i = 0; i < loai.Items.Count; i++) { if (loai.GetItemChecked(i)) { s_loai += dtloai.Rows[i]["id"].ToString().Trim() + ","; } } for (int i = 0; i < phieu.Items.Count; i++) { if (phieu.GetItemChecked(i)) { s_phieu += dtphieu.Rows[i]["id"].ToString().Trim() + ","; } } dtdmbd = d.get_data("select * from " + user + ".d_dmbd where nhom=" + int.Parse(nhom.SelectedValue.ToString())).Tables[0]; string cont = " and a.makp=" + int.Parse(makp.SelectedValue.ToString()) + " and a.nhom=" + int.Parse(nhom.SelectedValue.ToString()); cont += " and a.ngay between to_date('" + tu.Text + "'," + stime + ") and to_date('" + den.Text + "'," + stime + ")"; if (s_loai != "") { cont += " and a.loai in (" + s_loai.Substring(0, s_loai.Length - 1) + ")"; } if (s_phieu != "") { cont += " and a.phieu in (" + s_phieu.Substring(0, s_phieu.Length - 1) + ")"; } if (imp.Visible) { if (imp.Checked) { cont += " and c.manhom in (31,55)"; } else { cont += " and c.manhom not in (31,55)"; } } s_makho = ""; s_tenkho = ""; for (int i = 0; i < makho.Items.Count; i++) { if (makho.GetItemChecked(i)) { s_makho += dtkho.Rows[i]["id"].ToString().Trim() + ","; s_tenkho += dtkho.Rows[i]["ten"].ToString().Trim() + ";"; } } if (s_makho == "") { for (int i = 0; i < makho.Items.Count; i++) { s_makho += dtkho.Rows[i]["id"].ToString().Trim() + ","; s_tenkho += dtkho.Rows[i]["ten"].ToString().Trim() + ";"; } } // s_manhom = ""; s_tennhom = ""; for (int i = 0; i < dmnhom.Items.Count; i++) { if (dmnhom.GetItemChecked(i)) { s_manhom += dtdmnhom.Rows[i]["id"].ToString().Trim() + ","; s_tennhom += dtdmnhom.Rows[i]["ten"].ToString().Trim() + ";"; } } if (s_manhom == "") { for (int i = 0; i < dmnhom.Items.Count; i++) { s_manhom += dtdmnhom.Rows[i]["id"].ToString().Trim() + ","; s_tennhom += dtdmnhom.Rows[i]["ten"].ToString().Trim() + ";"; } } // if (s_makho != "") { cont += " and b.makho in (" + s_makho.Substring(0, s_makho.Length - 1) + ")"; } if (s_manhom.Trim().Trim(',') != "") { cont += " and c.manhom in(" + s_manhom.Trim().Trim(',') + ")"; } DateTime dt1 = d.StringToDate(tu.Text).AddDays(-d.iNgaykiemke); DateTime dt2 = d.StringToDate(den.Text).AddDays(d.iNgaykiemke); int y1 = dt1.Year, m1 = dt1.Month; int y2 = dt2.Year, m2 = dt2.Month; int itu, iden; string mmyy = ""; for (int i = y1; i <= y2; i++) { itu = (i == y1)?m1:1; iden = (i == y2)?m2:12; for (int j = itu; j <= iden; j++) { mmyy = j.ToString().PadLeft(2, '0') + i.ToString().Substring(2, 2); if (d.bMmyy(mmyy)) { get_xuat(mmyy, cont); get_hoantra(mmyy, cont); } } } sort(); }
private bool kiemtra() { songay = 0; soluot = 0; bSothe = int.Parse(m.sothe(int.Parse(madoituong.SelectedValue.ToString())).Substring(0, 2)) > 0; s_kho = ""; if (kho.CheckedItems.Count == 0) { for (int i = 0; i < kho.Items.Count; i++) { kho.SetItemCheckState(i, CheckState.Checked); } } for (int i = 0; i < kho.Items.Count; i++) { if (kho.GetItemChecked(i)) { s_kho += dtdmkho.Rows[i]["id"].ToString() + ","; } } dtso.Clear(); Tao_nhom(); Tao_dataset(); // DateTime dt1 = d.StringToDate(tu.Text).AddDays(-d.iNgaykiemke); DateTime dt2 = d.StringToDate(den.Text).AddDays(d.iNgaykiemke); int y1 = dt1.Year, m1 = dt1.Month; int y2 = dt2.Year, m2 = dt2.Month; int itu, iden; string mmyy = ""; for (int i = y1; i <= y2; i++) { itu = (i == y1)?m1:1; iden = (i == y2)?m2:12; for (int j = itu; j <= iden; j++) { mmyy = j.ToString().PadLeft(2, '0') + i.ToString().Substring(2, 2); if (d.bMmyy(mmyy)) { get_xuat(mmyy); } } } if (ds.Tables[0].Rows.Count == 0) { MessageBox.Show( lan.Change_language_MessageText("Không có số liệu !"), d.Msg); return(false); } i_cot = 0; dsxml.Merge(ds.Tables[0].Select("true", "stt,sothe1,sothe2,sothe3,sothe,ngayvao,mabn")); dsxml.Tables[0].Columns.Remove("STT"); dsxml.Tables[0].Columns.Remove("SOTHE1"); dsxml.Tables[0].Columns.Remove("SOTHE2"); dsxml.Tables[0].Columns.Remove("SOTHE3"); dsxml.Tables[0].Columns.Remove("ID"); dsxml.Tables[0].Columns.Remove("MABN"); dsxml.Tables[0].Columns.Remove("NGAYVAO"); dsxml.Tables[0].Columns.Remove("NGAYRA"); if (theo.SelectedIndex == 0) { dsxml.Tables[0].Columns.Remove("SONGAY"); dsxml.Tables[0].Columns.Remove("SOLUOT"); } else { if (!bSothe) { dsxml.Tables[0].Columns.Remove("SOTHE"); dsxml.Tables[0].Columns.Remove("SONGAY"); dsxml.Tables[0].Columns.Remove("SOLUOT"); i_cot = 4; } else { i_cot = 1; } dsxml.Tables[0].Columns.Remove("DIACHI"); dsxml.Tables[0].Columns.Remove("NGAYSINH"); dsxml.Tables[0].Columns.Remove("NOIDK"); } bCongkham = dsxml.Tables[0].Select("congkham<>0").Length > 0; dcongkham = 0; if (!bCongkham) { dsxml.Tables[0].Columns.Remove("CONGKHAM"); } else { foreach (DataRow r in dtso.Rows) { dcongkham += decimal.Parse(r["congkham"].ToString()); } } return(true); }