示例#1
0
        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 sql="select rownum as stt_t, b.makho,b.mabd,sum(b.soluong) soluong, c.ma, (c.ten||' '||c.hamluong) ten, c.tenhc, c.dang, d.ten tennguon, sum(b.soluong*b.giamua) sotien, round(b.sotien/b.soluong,3) dongia ";
             * sql+=" from d_xuatsdll a,"+tenfile+" b, d_dmbd c, d_dmnguon d, d_dmnhom e ";
             * sql+=" where a.id=b.id and b.mabd=c.id and b.manguon=d.id(+) and c.manhom=e.id and to_char(a.ngay,'dd/mm/yyyy')='"+s_ngay+"' and a.mmyy='"+s_mmyy+"'";
             * sql+=" and a.nhom="+i_nhom+" and a.loai="+i_loai+" and a.phieu="+i_phieu+" and a.makp="+i_makp;
             * if (s_madt!="" && tenfile=="d_thucxuat") sql+=" and b.madoituong in ("+s_madt.Substring(0,s_madt.Length-1)+")";
             * sql+=" and b.makho="+i_makho+" and e.nhomin="+i_nhomin;
             * if (s_manguon!="") sql+=" and b.manguon in ("+s_manguon.Substring(0,s_manguon.Length-1)+")";
             * sql+=" group by b.makho,b.mabd, c.ma, c.ten, c.hamluong, c.tenhc, c.dang, d.ten,round(b.sotien/b.soluong,3) , rownum ";
             * dsct=d.get_data(sql);
             */
            //
            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(i_nhom))
            {
                sql += " g.loai 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_nhomhang 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 g.loai=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) + ")";
                }
            }
            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(s_mmyy, 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()):"";
            //
        }