private void load_xuat_ct(int i_nhom, int i_loai, int i_phieu, int i_makp, int i_makho, string s_madt, string s_manguon, string s_ngay, int i_nhomin) { string tenfile = (i_loai == 2)?"d_thucbucstt":"d_thucxuat"; string s_user = d.user; string sql = "select rownum as stt,a.sttt,a.mabd,b.ma,trim(b.ten)||' '||b.hamluong ten,b.tenhc,b.dang,f.ten tenkho,c.ten tennguon,d.ten tennhomcc,a.handung,a.losx,a.soluong,round(a.sotien/a.soluong,3) dongia,a.sotien,a.giaban,a.makho,a.manguon,a.nhomcc,'xx/xx/xxxx' ngay,0 sttduyet,0 tutruc,"; sql += " b.manhom idnhom, i.stt, i.ten tennhom, b.mahang, g.ten tenhang,b.manuoc, j.ten tennuoc, "; sql += (s_madt != "" && tenfile == "d_thucxuat")?" e.doituong,a.madoituong,":"' ' doituong, 0 madoituong,"; if (d.bNoiNgoai_Hang(i_nhom) || d.bNoiNgoai_Nuoc(i_nhom)) { sql += " g.loai idnn, "; if (d.bNoiNgoai_Hang(i_nhom)) { sql += " h.ten noingoai "; } else { sql += " m.ten noingoai "; } sql += " from d_xuatsdll ll, " + tenfile + " a," + s_user + ".d_dmbd b," + s_user + ".d_dmnguon c," + s_user + ".d_nhomcc d," + s_user + ".d_dmkho f, " + s_user + ".d_dmhang g, " + s_user + ".d_nhomhang h, " + s_user + ".d_dmnhom i, " + s_user + ".d_dmnuoc j," + s_user + ".d_nhomnuoc m"; if (s_madt != "" && tenfile == "d_thucxuat") { sql += ", " + s_user + ".d_doituong e"; } sql += " where ll.id=a.id and a.mabd=b.id and a.manguon=c.id and a.nhomcc=d.id and a.makho=f.id "; sql += " and b.manhom=i.id and b.mahang=g.id and g.loai=h.id and b.manuoc=j.id and j.loai=m.id"; sql += " and to_char(ll.ngay,'dd/mm/yyyy')='" + s_ngay + "' and ll.mmyy='" + s_mmyy + "'"; sql += " and a.makho=" + i_makho + " and i.nhomin=" + i_nhomin + " and ll.nhom=" + i_nhom + " and ll.loai=" + i_loai + " and ll.phieu=" + i_phieu + " and ll.makp=" + i_makp; if (s_madt != "" && tenfile == "d_thucxuat") { sql += " and a.madoituong=e.madoituong and a.madoituong in (" + s_madt.Substring(0, s_madt.Length - 1) + ")"; } if (s_manguon != "") { sql += " and a.manguon in (" + s_manguon.Substring(0, s_manguon.Length - 1) + ")"; } } else { sql += " b.maloai idnn, h.ten noingoai "; sql += " from d_xuatsdll ll," + tenfile + " a," + s_user + ".d_dmbd b," + s_user + ".d_dmnguon c," + s_user + ".d_nhomcc d," + s_user + ".d_dmkho f, " + s_user + ".d_dmhang g, " + s_user + ".d_dmloai h, " + s_user + ".d_dmnhom i, " + s_user + ".d_dmnuoc j "; if (s_madt != "" && tenfile == "d_thucxuat") { sql += ", " + s_user + ".d_doituong e"; } sql += " where ll.id=a.id and a.mabd=b.id and a.manguon=c.id and a.nhomcc=d.id and a.makho=f.id "; sql += " and b.manhom=i.id and b.mahang=g.id and b.maloai=h.id and b.manuoc=j.id "; sql += " and to_char(ll.ngay,'dd/mm/yyyy')='" + s_ngay + "' and ll.mmyy='" + s_mmyy + "'"; sql += " and a.makho=" + i_makho + " and i.nhomin=" + i_nhomin + " and ll.nhom=" + i_nhom + " and ll.loai=" + i_loai + " and ll.phieu=" + i_phieu + " and ll.makp=" + i_makp; if (s_madt != "" && tenfile == "d_thucxuat") { sql += " and a.madoituong=e.madoituong and a.madoituong in (" + s_madt.Substring(0, s_madt.Length - 1) + ")"; } if (s_manguon != "") { sql += " and a.manguon in (" + s_manguon.Substring(0, s_manguon.Length - 1) + ")"; } } sql += " order by rownum"; // dsct = d.get_data(sql); dataGrid2.DataSource = dsct.Tables[0]; // co.Text = Load_sotk(dsct.Tables[0]); co.Tag = (dsct.Tables[0].Rows.Count > 0)?(dsct.Tables[0].Rows[0]["tenkho"].ToString()):""; // }