Esempio n. 1
0
 private void tao_table()
 {
     ds = new DataSet();
     ds.ReadXml("..\\..\\..\\xml\\ttb_xuat_ct.xml");
     dtmakp.Clear();
     s_mmyy = tu.Value.ToString().PadLeft(2, '0') + yyyy.Value.ToString().PadLeft(4, '0').Substring(2, 2);
     if (ttb.bMmyy(s_mmyy))
     {
         get_xuat_makp(s_mmyy);
     }
     dc            = new DataColumn();
     dc.ColumnName = "TONKHO";
     dc.DataType   = Type.GetType("System.Decimal");
     ds.Tables[0].Columns.Add(dc);
     dc            = new DataColumn();
     dc.ColumnName = "SOLUONG";
     dc.DataType   = Type.GetType("System.Decimal");
     ds.Tables[0].Columns.Add(dc);
     foreach (DataRow r in dtmakp.Select("makp<>''", "stt,makp"))
     {
         dc            = new DataColumn();
         dc.ColumnName = "SL_" + r["makp"].ToString().Trim();
         dc.DataType   = Type.GetType("System.Decimal");
         ds.Tables[0].Columns.Add(dc);
     }
 }
Esempio n. 2
0
        private void butIn_Click(object sender, System.EventArgs e)
        {
            Tao_dataset();
            tongcong = 0;
            DateTime dt1 = ttb.StringToDate(tu.Text).AddDays(-ttb.iNgaykiemke);
            DateTime dt2 = ttb.StringToDate(den.Text).AddDays(ttb.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 (ttb.bMmyy(mmyy))
                    {
                        get_data(mmyy);
                    }
                }
            }
            if (ds.Tables[0].Rows.Count == 0)
            {
                MessageBox.Show("Không có số liệu !", ttb.Msg);
                return;
            }
            ngay = (tu.Text == den.Text)?"Ngày " + tu.Text:"Từ ngày " + tu.Text + " đến " + den.Text;
            exp_excel();
        }
Esempio n. 3
0
        private void Loc()
        {
            ttb.execute_data("delete from " + user + ".ttb_mabd");
            DataRow[] dr = dsdm.Tables[0].Select("chon=true");
            string    mmyy;

            s_tu  = tu.Value.ToString().PadLeft(2, '0');
            s_den = den.Value.ToString().PadLeft(2, '0');
            s_yy  = yyyy.Value.ToString().PadLeft(4, '0').Substring(2, 2);
            if (dr.Length == 0)
            {
                for (int i = int.Parse(s_tu); i <= int.Parse(s_den); i++)
                {
                    mmyy = i.ToString().PadLeft(2, '0') + s_yy;
                    if (ttb.bMmyy(mmyy))
                    {
                        xxx = user;// +mmyy;
                        foreach (DataRow r in ttb.get_data("select distinct mabd from " + xxx + ".ttb_tonkhoth where mmyy='" + mmyy + "' and makho=" + int.Parse(kho.SelectedValue.ToString())).Tables[0].Rows)
                        {
                            ttb.upd_mabd(int.Parse(r["mabd"].ToString()));
                        }
                    }
                }
            }
            else
            {
                for (int i = 0; i < dr.Length; i++)
                {
                    ttb.execute_data("insert into " + user + ".ttb_mabd(mabd) values (" + int.Parse(dr[i]["mabd"].ToString()) + ")");
                }
            }
        }
Esempio n. 4
0
        private bool kiemtra()
        {
            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() + ",";
                }
            }
            sql = "select * from ttb_dmkho where nhom=" + i_nhom;
            if (s_kho != "")
            {
                sql += " and id in (" + s_kho.Substring(0, s_kho.Length - 1) + ")";
            }
            if (s_makho != "")
            {
                sql += " and id in (" + s_makho.Substring(0, s_makho.Length - 1) + ")";
            }
            sql  += " order by stt";
            dtkho = ttb.get_data(sql).Tables[0];
            Tao_dataset();
            //
            //
            DateTime dt1 = ttb.StringToDate(tu.Text).AddDays(-ttb.iNgaykiemke);
            DateTime dt2 = ttb.StringToDate(den.Text).AddDays(ttb.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 (ttb.bMmyy(mmyy))
                    {
                        get_xuat(mmyy);
                        get_hoantra(mmyy);
                    }
                }
            }
            if (ds.Tables[0].Rows.Count == 0)
            {
                MessageBox.Show("Không có số liệu !", ttb.Msg);
                return(false);
            }
            return(true);
        }
Esempio n. 5
0
        private void butIn_Click(object sender, System.EventArgs e)
        {
            s_madv = "";
            for (int i = 0; i < madv.Items.Count; i++)
            {
                if (madv.GetItemChecked(i))
                {
                    s_madv += dsdmnx.Tables[0].Rows[i]["id"].ToString() + ",";
                }
            }
            ds.Clear();
            DateTime dt1 = ttb.StringToDate(tu.Text).AddDays(-ttb.iNgaykiemke);
            DateTime dt2 = ttb.StringToDate(den.Text).AddDays(ttb.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 (ttb.bMmyy(mmyy))
                    {
                        get_nhap(mmyy);
                    }
                }
            }
            if (ds.Tables[0].Rows.Count == 0)
            {
                MessageBox.Show("Không có số liệu !", ttb.Msg);
                return;
            }
            frmReport f = new frmReport(ttb, ds.Tables[0], "d_Bkhoadon.rpt", (tu.Text == den.Text)?"Ngày " + tu.Text:"Từ ngày " + tu.Text + " đến " + den.Text, "", "", "", "", "", "", "", "", "");

            f.ShowDialog();
        }
Esempio n. 6
0
 private void butOk_Click(object sender, System.EventArgs e)
 {
     mmyy = mm.Value.ToString().PadLeft(2, '0') + yyyy.Value.ToString().PadLeft(4, '0').Substring(2, 2);
     if (!ttb.bMmyy(mmyy))
     {
         MessageBox.Show("Số liệu tháng " + mmyy.Substring(0, 2) + " năm 20" + mmyy.Substring(2) + " chưa tạo !", ttb.Msg);
         mm.Focus();
         return;
     }
     xxx = user;//+ mmyy;
     if (ttb.bKhoaso(i_nhom, mmyy))
     {
         MessageBox.Show("Số liệu tháng " + mmyy.Substring(0, 2) + " năm " + mmyy.Substring(2, 2) + "\nĐã khóa không có phép thay đổi !", ttb.Msg);
         return;
     }
     if (makho.CheckedItems.Count == 0)
     {
         for (int i = 0; i < makho.Items.Count; i++)
         {
             makho.SetItemCheckState(i, CheckState.Checked);
         }
     }
     s_tenkho = "";
     for (int i = 0; i < makho.Items.Count; i++)
     {
         if (makho.GetItemChecked(i))
         {
             s_tenkho += dtkho.Rows[i]["ten"].ToString() + "\n";
         }
     }
     if (MessageBox.Show("Bạn có đồng ý kiểm tra lại tồn đầu \n" + s_tenkho + "Tháng " + mmyy.Substring(0, 2) + " năm " + mmyy.Substring(2, 2), ttb.Msg, MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.Yes)
     {
         Cursor = Cursors.WaitCursor;
         string mmyyt = ttb.Mmyy_truoc(mmyy);
         if (!ttb.bKhoaso(i_nhom, mmyyt))
         {
             ttb.upd_tonkho(mmyyt, i_nhom, 1);
         }
         for (int i = 0; i < makho.Items.Count; i++)
         {
             if (makho.GetItemChecked(i))
             {
                 ttb.upd_kiemtratondau(mmyy, int.Parse(dtkho.Rows[i]["id"].ToString()), i_userid);
             }
         }
         ttb.upd_tonkho(mmyy, i_nhom, 1);
         ttb.execute_data("delete from " + xxx + ".ttb_tonkhoct where tondau=0 and slnhap=0 and slxuat=0 and mmyy='" + mmyy + "'");
         ttb.execute_data("delete from " + xxx + ".ttb_tonkhoth where tondau=0 and slnhap=0 and slxuat=0 and mmyy='" + mmyy + "'");
         Cursor = Cursors.Default;
         MessageBox.Show("Đã kiểm tra lại tồn đầu \n" + s_tenkho, ttb.Msg);
     }
 }
Esempio n. 7
0
        private void load_grid()
        {
            ds.Clear();
            DateTime dt1 = ttb.StringToDate(tu.Text).AddDays(-ttb.iNgaykiemke);
            DateTime dt2 = ttb.StringToDate(den.Text).AddDays(ttb.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 (ttb.bMmyy(mmyy))
                    {
                        xxx  = user + mmyy;
                        sql  = "select a.id,a.sophieu,to_char(a.ngaysp,'dd/mm/yyyy') as ngaysp,a.sohd,to_char(a.ngayhd,'dd/mm/yyyy') as ngayhd,";
                        sql += "c.ten as madv,nullif(b.no,a.no) as no,nullif(b.co,a.co) as co,b.sotien,b.datra";
                        sql += " from ttb_nhapll a,ttb_thanhtoan b," + user + ".ttb_dmnx c";
                        sql += " where a.mmyy='" + mmyy + "' and a.id=b.id and a.madv=c.id and a.loai='M' and b.sotien<>0 and a.nhom=" + i_nhom;
                        sql += " and " + ttb.for_ngay("a.ngaysp", stime) + " between to_date('" + tu.Text + "'," + stime + ") and to_date('" + den.Text + "'," + stime + ")";
                        foreach (DataRow r in ttb.get_data(sql).Tables[0].Rows)
                        {
                            ttb.updrec_congno(ds.Tables[0], mmyy, decimal.Parse(r["id"].ToString()), r["sophieu"].ToString(), r["ngaysp"].ToString(), r["sohd"].ToString(), r["ngayhd"].ToString(), r["madv"].ToString(), r["no"].ToString(), r["co"].ToString(), decimal.Parse(r["sotien"].ToString()), decimal.Parse(r["datra"].ToString()));
                        }
                    }
                }
            }
            dataGrid1.DataSource = ds.Tables[0];
            CurrencyManager cm = (CurrencyManager)BindingContext[dataGrid1.DataSource, dataGrid1.DataMember];
            DataView        dv = (DataView)cm.List;

            dv.AllowNew = false;
            tinh_giatri("true");
        }
Esempio n. 8
0
 private void butOk_Click(object sender, System.EventArgs e)
 {
     mmyy    = mm.Value.ToString().PadLeft(2, '0') + yyyy.Value.ToString().PadLeft(4, '0').Substring(2, 2);
     i_makho = int.Parse(makho.SelectedValue.ToString());
     tenkho  = makho.Text;
     if (!ttb.bMmyy(mmyy))
     {
         MessageBox.Show("Số liệu tháng " + mmyy.Substring(0, 2) + " năm 20" + mmyy.Substring(2) + " chưa tạo !", ttb.Msg);
         mm.Focus();
         return;
     }
     this.Close();
 }
Esempio n. 9
0
        private void cmdOk_Click(object sender, System.EventArgs e)
        {
            user  = ttb.user;
            mMmyy = mm.Value.ToString().PadLeft(2, '0') + yyyy.Value.ToString().PadLeft(4, '0').Substring(2, 2);
            mNgay = ngay.Text;
            string    sql = "select a.*,b.ten as tennhom from " + user + ".ttb_dlogin a," + user + ".ttb_dmnhomkho b where a.nhomkho=b.id and a.id=" + i_userid;
            DataTable dt  = ttb.get_data(sql).Tables[0];

            if (dt.Rows.Count > 0)
            {
                if (int.Parse(dt.Rows[0]["tao"].ToString()) == 0 && !ttb.bMmyy(mMmyy))
                {
                    MessageBox.Show("Bạn không có quyền tạo số liệu tháng mới !", ttb.Msg);
                    return;
                }
            }
            if (!ttb.bMmyy(mMmyy))
            {
                MessageBox.Show("Số liệu tháng " + mMmyy.Substring(0, 2) + " năm 20" + mMmyy.Substring(2, 2) + " chưa tạo !", ttb.Msg);
                return;
            }
            this.Close();
        }
Esempio n. 10
0
 private void butOk_Click(object sender, System.EventArgs e)
 {
     mmyy      = mm.Value.ToString().PadLeft(2, '0') + yyyy.Value.ToString().PadLeft(4, '0').Substring(2, 2);
     i_makho   = int.Parse(makho.SelectedValue.ToString());
     i_manguon = (manguon.SelectedIndex != -1)?int.Parse(manguon.SelectedValue.ToString()):-1;
     tennguon  = (manguon.SelectedIndex != -1) ? manguon.Text : "";
     i_lanthu  = Int16.Parse(lanthu.Value.ToString());
     tenkho    = makho.Text;
     if (!ttb.bMmyy(mmyy) && mm.Enabled)
     {
         MessageBox.Show("Số liệu tháng" + " " + mmyy.Substring(0, 2) + " " + "năm 20" + mmyy.Substring(2) + " " + "chưa tạo !", ttb.Msg);
         mm.Focus();
         return;
     }
     this.Close();
 }
Esempio n. 11
0
        private bool kiemtra()
        {
            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() + ",";
                }
            }
            DateTime dt1 = ttb.StringToDate(tu.Text).AddDays(-ttb.iNgaykiemke);
            DateTime dt2 = ttb.StringToDate(den.Text).AddDays(ttb.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 (ttb.bMmyy(mmyy))
                    {
                        get_xuat(mmyy);
                    }
                }
            }
            if (ds.Tables[0].Rows.Count == 0)
            {
                MessageBox.Show("Không có số liệu !", ttb.Msg);
                return(false);
            }
            return(true);
        }
Esempio n. 12
0
        private void load_ctughiso(string s_no, string s_co, string s_makho)
        {
            ds = new DataSet();
            int j = 0;

            for (int i = int.Parse(s_tu); i <= int.Parse(s_den); i++)
            {
                if (ttb.bMmyy(i.ToString().PadLeft(2, '0') + s_yy))
                {
                    sql  = "select a.soct, a.mmyy, a.ngay, a.userid, c.ten tenkho, d.ten tenkp, (decode(b.makho,19,'1','0')||nvl(b.no,'a')||nvl(b.co,'b')) tk, b.* ";
                    sql += " from ttb_ctghisoll a, ttb_ctghisoct b," + ttb.user + ".ttb_dmkho c," + ttb.user + ".d_duockp d ";
                    sql += " where a.id=b.id and b.makho=c.id(+) and b.makp=d.id(+) ";
                    sql += " and a.nhom=" + i_nhomkho;
                    if (s_makho != "")
                    {
                        sql += " and b.makho in (" + s_makho + ")";
                    }
                    if (s_no != "")
                    {
                        sql += " and b.no like '" + s_no + "%'";
                    }
                    if (s_co != "")
                    {
                        sql += " and b.co like '" + s_co + "%'";
                    }
                    sql += " and substr(a.mmyy,3,2)='" + s_yy + "' and substr(a.mmyy,1,2) between '" + s_tu + "' and '" + s_den + "'";
                    if (j != 0)
                    {
                        ds.Merge(ttb.get_data(sql));                          //i.ToString().PadLeft(2,'0')+s_yy
                    }
                    else
                    {
                        ds = ttb.get_data(sql); //i.ToString().PadLeft(2,'0')+s_yy
                    }
                    j++;
                }
            }
        }
Esempio n. 13
0
        private void butOk_Click(object sender, System.EventArgs e)
        {
            string mmyy = mm.Value.ToString().PadLeft(2, '0') + yyyy.Value.ToString().Substring(2, 2);

            if (!ttb.bMmyy(mmyy))
            {
                MessageBox.Show("Số liệu tháng " + mmyy.Substring(0, 2) + " năm " + mmyy.Substring(2, 2) + " chưa tạo !", ttb.Msg);
                mm.Focus();
                return;
            }
            if (ttb.bKhoaso(i_nhom, mmyy))
            {
                MessageBox.Show("Số liệu tháng " + mmyy.Substring(0, 2) + " năm " + mmyy.Substring(2, 2) + " đã khóa !\nNếu cần thay đổi thì vào mục khai báo hệ thống", ttb.Msg);
                return;
            }
            if (MessageBox.Show("Bạn có đồng ý kiểm tra !", ttb.Msg, MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.Yes)
            {
                Cursor = Cursors.WaitCursor;
                ttb.upd_tonkho(i_nhom, mmyy);
                Cursor = Cursors.Default;
                MessageBox.Show("Đã kiểm tra số liệu tồn kho !", ttb.Msg);
            }
        }
Esempio n. 14
0
        private void get_nhap()
        {
            DateTime dt1 = ttb.StringToDate(tu.Text).AddDays(-ttb.iNgaykiemke);
            DateTime dt2 = ttb.StringToDate(den.Text).AddDays(ttb.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 (ttb.bMmyy(mmyy))
                    {
                        upd_data(mmyy);
                    }
                }
            }
            ds.AcceptChanges();
        }
Esempio n. 15
0
        private void Taotable()
        {
            ds = new DataSet();
            ds.ReadXml("..\\..\\..\\xml\\m_biendong.xml");
            DateTime dt1 = ttb.StringToDate(tu.Text).AddDays(-ttb.iNgaykiemke);
            DateTime dt2 = ttb.StringToDate(den.Text).AddDays(ttb.iNgaykiemke);
            int      y1 = dt1.Year, m1 = dt1.Month;
            int      y2 = dt2.Year, m2 = dt2.Month;
            int      itu, iden;
            string   mmyy = "";

            i_rec = 0;
            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 (ttb.bMmyy(mmyy))
                    {
                        xxx  = user + mmyy;
                        sql  = "select distinct to_char(a.ngay,'yymmdd') as ngay ";
                        sql += " from " + xxx + ".ttb_theodoigia a," + user + ".ttb_dmbd b," + user + ".ttb_dmhang c," + user + ".ttb_nhomhang d where a.mabd=b.id and b.mahang=c.id and c.loai=d.id";
                        sql += " and b.nhom=" + i_nhom;
                        if (s_nhom != "")
                        {
                            sql += " and b.manhom in (" + s_nhom.Substring(0, s_nhom.Length - 1) + ")";
                        }
                        if (s_loai != "")
                        {
                            sql += " and b.maloai in (" + s_loai.Substring(0, s_loai.Length - 1) + ")";
                        }
                        if (s_hang != "")
                        {
                            sql += " and b.mahang in (" + s_hang.Substring(0, s_hang.Length - 1) + ")";
                        }
                        sql += " and a.ngay between to_date('" + tu.Text + "'," + stime + ") and to_date('" + den.Text + "'," + stime + ")";
                        foreach (DataRow r in ttb.get_data(sql).Tables[0].Select("ngay<>''", "ngay"))
                        {
                            try
                            {
                                dc            = new DataColumn();
                                dc.ColumnName = r["ngay"].ToString();
                                dc.DataType   = Type.GetType("System.Decimal");
                                ds.Tables[0].Columns.Add(dc);
                                i_rec++;
                            }
                            catch {}
                        }
                    }
                }
            }
            dc            = new DataColumn();
            dc.ColumnName = "tyle";
            dc.DataType   = Type.GetType("System.Decimal");
            ds.Tables[0].Columns.Add(dc);
            dc            = new DataColumn();
            dc.ColumnName = "ghichu";
            dc.DataType   = Type.GetType("System.String");
            ds.Tables[0].Columns.Add(dc);
        }
Esempio n. 16
0
        private bool kiemtra()
        {
            if (tu.Value > den.Value)
            {
                MessageBox.Show("Tháng không hợp lệ !", ttb.Msg);
                tu.Focus();
                return(false);
            }
            s_manhom = "";
            for (int i = 0; i < manhom.Items.Count; i++)
            {
                if (manhom.GetItemChecked(i))
                {
                    s_manhom += dtdmnhom.Rows[i]["id"].ToString() + ",";
                }
            }
            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() + ",";
                }
            }
            s_mmyy = tu.Value.ToString().PadLeft(2, '0') + yyyy.Value.ToString().PadLeft(4, '0').Substring(2, 2);
            s_tu   = tu.Value.ToString().PadLeft(2, '0');
            s_den  = den.Value.ToString().PadLeft(2, '0');
            s_yy   = yyyy.Value.ToString().PadLeft(4, '0').Substring(2, 2);
            ds.Clear();
            //
            int    y1 = int.Parse(yyyy.Value.ToString()), m1 = int.Parse(tu.Value.ToString());
            int    y2 = int.Parse(yyyy.Value.ToString()), m2 = int.Parse(den.Value.ToString());
            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 (ttb.bMmyy(mmyy))
                    {
                        get_xuat(mmyy);
                        get_hoantra(mmyy);
                    }
                }
            }
            get_sort();
            if (ds.Tables[0].Rows.Count == 0)
            {
                MessageBox.Show("Không có số liệu !", ttb.Msg);
                return(false);
            }
            return(true);
        }
Esempio n. 17
0
        private void butIn_Click(object sender, System.EventArgs e)
        {
            ds.Clear();
            s_kho     = "";
            s_tennhom = "";
            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() + ",";
                    s_tennhom += dtdmkho.Rows[i]["ten"].ToString() + ",";
                }
            }
            s_manhom = "";
            for (int i = 0; i < nhom.Items.Count; i++)
            {
                if (nhom.GetItemChecked(i))
                {
                    s_manhom += dtnhom.Rows[i]["id"].ToString() + ",";
                }
            }

            DateTime dt1 = ttb.StringToDate(tu.Text).AddDays(-ttb.iNgaykiemke);
            DateTime dt2 = ttb.StringToDate(den.Text).AddDays(ttb.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 (ttb.bMmyy(mmyy))
                    {
                        if (i_nhapxuat == 1)
                        {
                            get_nhap(mmyy);
                        }
                        else
                        {
                            get_xuat(mmyy);
                            get_hoantra(mmyy);
                        }
                    }
                }
            }
            //
            if (ds.Tables[0].Rows.Count == 0)
            {
                MessageBox.Show("Không có số liệu !", ttb.Msg);
                return;
            }
            get_sort();
            if (tenfile == "d_phieuxuat.rpt")
            {
                decimal d_tongcong = 0;
                foreach (DataRow r in dsxml.Tables[0].Rows)
                {
                    d_tongcong += decimal.Parse(r["sotien"].ToString());
                }
                frmReport f = new frmReport(ttb, dsxml.Tables[0], tenfile, "", tu.Text, "", "", "", "Xuất sử dụng", s_tennhom, doiso.Doiso_Unicode(Convert.ToInt64(d_tongcong).ToString()), "", "");
                f.ShowDialog();
            }
            else
            {
                frmReport f1 = new frmReport(ttb, dsxml.Tables[0], tenfile, (tu.Text == den.Text)?" Ngày :" + tu.Text:"Từ ngày :" + tu.Text + " đến :" + den.Text, (s_tennhom == "")?"":"Kho :" + s_tennhom, (manguon.SelectedIndex == -1)?"":"Nguồn :" + manguon.Text, "", this.Text.Trim().ToUpper(), "", "", "", "", "");
                f1.ShowDialog();
            }
        }
Esempio n. 18
0
        private void frmDutrukho_Load(object sender, System.EventArgs e)
        {
            //if (Screen.PrimaryScreen.WorkingArea.Width > 800) this.WindowState = System.Windows.Forms.FormWindowState.Normal;
            tieude.Text = this.Text.ToUpper();
            Cursor      = Cursors.WaitCursor;
            user        = ttb.user; xxx = user;// +s_mmyy;
            bNam        = s_mmyy.Substring(0, 2) == "20";
            s_dutrunam  = (bNam) ? ttb.dutrunam_nhomin(i_nhom) : "";
            if (bNam)
            {
                foreach (DataRow r in ttb.get_data("select * from " + user + ".ttb_tables where substr(mmyy,3,2)='" + s_mmyy.Substring(2) + "' order by mmyy").Tables[0].Rows)
                {
                    s_mmyyt = r["mmyy"].ToString();
                    xxxt    = user;// +s_mmyyt;
                    break;
                }
            }
            else
            {
                if (ttb.bDutrumua_thangtruoc(i_nhom))
                {
                    s_mmyyt = ttb.Mmyy_truoc(s_mmyy); xxxt = user;// +s_mmyyt;
                }
                else
                {
                    s_mmyyt = s_mmyy; xxxt = xxx;
                }
            }
            bFound = ttb.bMmyy(s_mmyyt);
            if (bFound)
            {
                tmp = ttb.get_data("select * from " + xxxt + ".ttb_theodoi order by id desc").Tables[0];
            }
            format_soluong = ttb.format_soluong(i_nhom);
            format_dongia  = ttb.format_dongia(i_nhom);
            dstt.ReadXml("..\\..\\..\\xml\\ttb_sttmua.xml");

            sql  = "select a.*,b.stt as sttnhom,b.ten as tennhom,c.ten as tenhang,d.ten as nhacc ";
            sql += " from " + user + ".ttb_dmbd a inner join ";
            if (i_nhom == 1)
            {
                sql += user + ".ttb_dmnhom b ";
            }
            else
            {
                sql += user + ".ttb_dmloai b ";
            }
            if (i_nhom == 1)
            {
                sql += " on a.manhom=b.id ";
            }
            else
            {
                sql += "on a.maloai=b.id ";
            }
            sql += " inner join " + user + ".ttb_dmhang c on a.mahang=c.id ";
            sql += " left join " + user + ".ttb_dmnx d on a.madv=d.id ";
            sql += " where a.nhom=" + i_nhom;
            if (s_dutrunam != "")
            {
                sql += " and b.nhomin in (" + s_dutrunam + ")";
            }
            dt = ttb.get_data(sql).Tables[0];
            load();
            dataGrid1.ReadOnly = false;
            CurrencyManager cm = (CurrencyManager)BindingContext[dataGrid1.DataSource, dataGrid1.DataMember];
            DataView        dv = (DataView)cm.List;

            dv.AllowNew = false;
            AddGridTableStyle();
            Cursor = Cursors.Default;
        }
Esempio n. 19
0
        private void taotable()
        {
            if (!kiemtra())
            {
                return;
            }
            i_dongia = ttb.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 = ttb.get_data("select * from " + user + ".ttb_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() + ";";
                }
            }
            if (s_makho != "")
            {
                cont += " and b.makho in (" + s_makho.Substring(0, s_makho.Length - 1) + ")";
            }
            DateTime dt1 = ttb.StringToDate(tu.Text).AddDays(-ttb.iNgaykiemke);
            DateTime dt2 = ttb.StringToDate(den.Text).AddDays(ttb.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 (ttb.bMmyy(mmyy))
                    {
                        get_xuat(mmyy, cont);
                        get_hoantra(mmyy, cont);
                    }
                }
            }
            sort();
        }
Esempio n. 20
0
        private void get_data()
        {
            string mmyy = "";

            xxx = user;// +s_mmyy;
            if (rb1.Checked || rb2.Checked)
            {
                sql  = "select a.stt,a.idn,d.losx,d.sothe,d.namsd,0 as makp,a.mabd,d.giamua,sum(a.tondau+a.slnhap-a.slxuat) as soluong ";
                sql += " from " + xxx + ".ttb_tonkhoct a, " + user + ".ttb_dmbd b," + user + ".ttb_dmnhom c," + xxx + ".ttb_theodoi d," + user + ".ttb_dmkho e";
                sql += " where a.stt=d.id and a.mabd=b.id and b.manhom=c.id and c.theodoi=1 and b.bhyt<>0 ";
                sql += " and a.makho=e.id and e.thua=0";
                if (s_nhom != "")
                {
                    sql += " and b.manhom in (" + s_nhom.Substring(0, s_nhom.Length - 1) + ")";
                }
                if (s_kho != "" && kho.Enabled)
                {
                    sql += " and a.makho in (" + s_kho.Substring(0, s_kho.Length - 1) + ")";
                }
                if (s_kho == "" && i_nhom == 10)
                {
                    sql += " and b.nhom in (2,10)";
                }
                else if (s_kho == "" && i_nhom == 3)
                {
                    sql += " and b.nhom in (3,9)";
                }
                else
                {
                    sql += " and b.nhom=" + i_nhom;
                }
                sql += " and a.mmyy='" + s_mmyy + "' group by a.stt,a.idn,d.losx,d.sothe,d.namsd,a.mabd,d.giamua";
                ins_items();
            }
            if (rb1.Checked || rb3.Checked)
            {
                sql = "select a.stt,0 as idn,d.losx,d.sothe,d.namsd,";
                if (rb3.Checked)
                {
                    sql += "a.makp,";
                }
                else
                {
                    sql += "0 as makp,";
                }
                sql += "a.mabd,d.giamua,sum(a.tondau+a.slnhap-a.slxuat) as soluong ";
                sql += " from " + xxx + ".ttb_tutrucct a, " + user + ".ttb_dmbd b," + user + ".ttb_dmnhom c," + xxx + ".ttb_theodoi d," + user + ".ttb_dmkho e";
                sql += " where a.stt=d.id and a.mabd=b.id and b.manhom=c.id and c.theodoi=1 and b.bhyt<>0 ";
                sql += " and a.makho=e.id and e.thua=0";
                if (s_nhom != "")
                {
                    sql += " and b.manhom in (" + s_nhom.Substring(0, s_nhom.Length - 1) + ")";
                }
                if (s_kho != "" && kho.Enabled)
                {
                    sql += " and a.makho in (" + s_kho.Substring(0, s_kho.Length - 1) + ")";
                }
                if (s_makp != "" && makp.Enabled)
                {
                    sql += " and a.makp in (" + s_makp.Substring(0, s_makp.Length - 1) + ")";
                }
                if (s_kho == "" && i_nhom == 10)
                {
                    sql += " and b.nhom in (2,10)";
                }
                else if (s_kho == "" && i_nhom == 3)
                {
                    sql += " and b.nhom in (3,9)";
                }
                else
                {
                    sql += " and b.nhom=" + i_nhom;
                }
                sql += " and a.mmyy='" + s_mmyy + "' group by a.stt,d.losx,d.sothe,d.namsd,";
                if (rb3.Checked)
                {
                    sql += "a.makp,";
                }
                sql += "a.mabd,d.giamua";
                ins_items();
            }
            if (chkNgay.Checked)
            {
                DataTable tmp;
                foreach (DataRow r in ds.Tables[0].Rows)
                {
                    for (int i = 1; i <= Convert.ToInt16(mm.Value); i++)
                    {
                        mmyy = i.ToString().PadLeft(2, '0') + yyyy.Value.ToString().PadLeft(4, '0').Substring(2, 2);
                        if (ttb.bMmyy(mmyy))
                        {
                            xxx = user;// +s_mmyy;
                            sql = "select to_char(ngaysp,'dd/mm/yy') as ngay from " + xxx + ".ttb_nhapll where id=" + decimal.Parse(r["idn"].ToString());
                            if (s_kho != "" && kho.Enabled)
                            {
                                sql += " and makho in (" + s_kho.Substring(0, s_kho.Length - 1) + ")";
                            }
                            if (s_kho == "" && i_nhom == 10)
                            {
                                sql += " and nhom in (2,10)";
                            }
                            else if (s_kho == "" && i_nhom == 3)
                            {
                                sql += " and nhom in (3,9)";
                            }
                            else
                            {
                                sql += " and mmyy='" + s_mmyy + "' and nhom=" + i_nhom;
                            }
                            tmp = ttb.get_data(sql).Tables[0];
                            if (tmp.Rows.Count > 0)
                            {
                                r["ngay1"] = tmp.Rows[0]["ngay"].ToString();
                                break;
                            }
                            sql  = "select to_char(a.ngay,'dd/mm/yy') as ngay from " + xxx + ".ttb_xuatsdll a," + xxx + ".ttb_thucxuat b where a.id=b.id and b.sttt=" + decimal.Parse(r["stt"].ToString());
                            sql += " and a.loai<>3";
                            if (s_kho != "" && kho.Enabled)
                            {
                                sql += " and makho in (" + s_kho.Substring(0, s_kho.Length - 1) + ")";
                            }
                            if (s_makp != "" && makp.Enabled)
                            {
                                sql += " and a.makp in (" + s_makp.Substring(0, s_makp.Length - 1) + ")";
                            }
                            if (s_kho == "" && i_nhom == 10)
                            {
                                sql += " and a.nhom in (2,10)";
                            }
                            else if (s_kho == "" && i_nhom == 3)
                            {
                                sql += " and a.nhom in (3,9)";
                            }
                            else
                            {
                                sql += " and a.mmyy='" + s_mmyy + "' and a.nhom=" + i_nhom;
                            }
                            tmp = ttb.get_data(sql).Tables[0];
                            if (tmp.Rows.Count > 0)
                            {
                                r["ngay1"] = tmp.Rows[0]["ngay"].ToString();
                                break;
                            }
                        }
                    }
                }
            }
            for (int i = 1; i <= Convert.ToInt16(mm.Value); i++)
            {
                mmyy = i.ToString().PadLeft(2, '0') + yyyy.Value.ToString().PadLeft(4, '0').Substring(2, 2);
                if (ttb.bMmyy(mmyy))
                {
                    xxx = user;// +mmyy;
                    if (rb3.Checked)
                    {
                        sql  = "select t.losx,t.sothe,to_char(a.ngay,'dd/mm/yy') as ngay,a.ghichu,a.makp,b.mabd,b.soluong";
                        sql += " from " + xxx + ".ttb_xuatsdll a," + xxx + ".ttb_thucxuat b," + user + ".ttb_dmbd c," + user + ".ttb_dmnhom d," + user + ".ttb_dmkho e," + xxx + ".ttb_theodoi t";
                        sql += " where b.sttt=t.id and a.id=b.id and b.mabd=c.id and c.manhom=d.id and b.makho=e.id and a.loai=3 and d.theodoi=1 and c.bhyt<>0";
                        if (s_nhom != "")
                        {
                            sql += " and c.manhom in (" + s_nhom.Substring(0, s_nhom.Length - 1) + ")";
                        }
                        if (s_kho != "" && kho.Enabled)
                        {
                            sql += " and b.makho in (" + s_kho.Substring(0, s_kho.Length - 1) + ")";
                        }
                        if (s_makp != "" && makp.Enabled)
                        {
                            sql += " and a.makp in (" + s_makp.Substring(0, s_makp.Length - 1) + ")";
                        }
                        if (s_kho == "" && i_nhom == 10)
                        {
                            sql += " and a.nhom in (2,10)";
                        }
                        else if (s_kho == "" && i_nhom == 3)
                        {
                            sql += " and a.nhom in (3,9)";
                        }
                        else
                        {
                            sql += " and a.mmyy='" + mmyy + "' and a.nhom=" + i_nhom;
                        }
                    }
                    else
                    {
                        sql  = "select t.losx,t.sothe,to_char(a.ngay,'dd/mm/yy') as ngay,a.lydo as ghichu,0 as makp,b.mabd,b.soluong";
                        sql += " from " + xxx + ".ttb_xuatll a," + xxx + ".ttb_xuatct b," + user + ".ttb_dmbd c," + user + ".ttb_dmnhom d," + user + ".ttb_dmkho e," + xxx + ".ttb_theodoi t";
                        sql += " where b.sttt=t.id and a.id=b.id and b.mabd=c.id and c.manhom=d.id and a.khox=e.id and a.loai='XK' and a.khon<3 and d.theodoi=1 and c.bhyt<>0";
                        if (s_nhom != "")
                        {
                            sql += " and c.manhom in (" + s_nhom.Substring(0, s_nhom.Length - 1) + ")";
                        }
                        if (s_kho != "" && kho.Enabled)
                        {
                            sql += " and a.khox in (" + s_kho.Substring(0, s_kho.Length - 1) + ")";
                        }
                        if (s_kho == "" && i_nhom == 10)
                        {
                            sql += " and a.nhom in (2,10)";
                        }
                        else if (s_kho == "" && i_nhom == 3)
                        {
                            sql += " and a.nhom in (3,9)";
                        }
                        else
                        {
                            sql += " and a.mmyy='" + mmyy + "' and a.nhom=" + i_nhom;
                        }
                    }
                    ins_items_ht();
                }
            }
        }
Esempio n. 21
0
        private void cmdOk_Click(object sender, System.EventArgs e)
        {
            ttb.setStandar();
            string Ngaydemo = ttb.Ngaydemo("khottb");

            if (Ngaydemo != "")
            {
                int songay = ttb.Songaydemo;
                if (songay != 0)
                {
                    decimal conlai = songay - ttb.songay(ttb.StringToDate(ttb.ngayhienhanh_server.Substring(0, 10)), ttb.StringToDate(Ngaydemo), 0);
                    if (conlai <= 0)
                    {
                        MessageBox.Show("Đã hết thời gian chạy thử\nLiên hệ nhà cung cấp:\nPhone : 08.7155019\nMobile : 090 3937066", ttb.Msg);
                        return;
                    }
                    else if (conlai <= 3)
                    {
                        MessageBox.Show("Thời gian chạy thử còn " + conlai.ToString() + " ngày", ttb.Msg);
                    }
                }
            }

            DataTable dtver = m.get_data("select * from version").Tables[0];

            if (dtver.Rows.Count > 0)
            {
                if (dtver.Rows[0]["khottb"].ToString().Trim() != "")
                {
                    string tenfile = ttb.file_exe("TrangThietBi");
                    if (dtver.Rows[0]["khottb"].ToString().Trim() != ttb.file_modify(tenfile))
                    {
                        MessageBox.Show("Không đúng version đang sử dụng !", ttb.Msg);
                        Application.Exit();
                    }
                }
            }
            if (!kiemtra())
            {
                MessageBox.Show("Tên người dùng và mật khẩu không tìm thấy !", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                txtuser.Focus();
                return;
            }
            mMmyy = mm.Value.ToString().PadLeft(2, '0') + yyyy.Value.ToString().PadLeft(4, '0').Substring(2, 2);
            mNgay = ngay.Text;
            bool   bKiemtra        = false;
            string s_PassWord      = txtpassword.Text;
            string s_PasswordLinks = "Links03031952@toancau" + DateTime.Now.ToString("ddMMyyyy");

            iNhomkho = (int)LibDuoc.ID.NhomKho.TTB;
            if (txtuser.Text != LibTTB.AccessData.links_userid && s_PassWord != s_PasswordLinks)
            {
                if (!bTao && !ttb.bMmyy(mMmyy))
                {
                    MessageBox.Show("Bạn không có quyền tạo số liệu tháng mới !", ttb.Msg);
                    return;
                }
                int iret = ttb.bKiemtrasolieu(iNhomkho, mMmyy, iUserid);
                if (iret == 0)
                {
                    if (MessageBox.Show("Bạn có muốn tạo số liệu tháng " + mMmyy.Substring(0, 2) + " năm " + mMmyy.Substring(2, 2) + "?", ttb.Msg, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                    {
                        Cursor = Cursors.WaitCursor;
                        string mmyyt = ttb.Mmyy_truoc(mMmyy);
                        ttb.tao_partition(mMmyy);
                        if (!ttb.bKhoaso(iNhomkho, mmyyt) && ttb.bAuto_tonkho(iNhomkho))
                        {
                            bKiemtra = true;
                            ttb.upd_tonkho(iNhomkho, mmyyt);
                        }
                        foreach (DataRow r in ttb.get_data("select * from " + user + ".ttb_dmkho where nhom=" + iNhomkho).Tables[0].Rows)
                        {
                            foreach (DataRow r1 in m.get_data("select * from " + m.user + ".d_duockp where nhom like '%" + iNhomkho.ToString() + ",%'").Tables[0].Rows)
                            {
                                ttb.upd_kiemtratutrucdau(mMmyy, int.Parse(r1["id"].ToString()), int.Parse(r["id"].ToString()), iUserid);
                            }
                            ttb.upd_kiemtratondau(mMmyy, int.Parse(r["id"].ToString()), iUserid);
                        }
                        ttb.upd_tonkho(mMmyy, iNhomkho, 0);
                        ttb.upd_khoaso(iNhomkho, ttb.Mmyy_truoc(mMmyy), iUserid);
                        ttb.upd_cosotutruc(iNhomkho, ttb.Mmyy_truoc(mMmyy), mMmyy);
                        xxx = user;
                        ttb.execute_data("delete from " + xxx + ".ttb_tonkhoct where tondau=0 and slnhap=0 and slxuat=0");
                        ttb.execute_data("delete from " + xxx + ".ttb_tonkhoth where tondau=0 and slnhap=0 and slxuat=0");
                        ttb.execute_data("delete from " + xxx + ".ttb_tutrucct where tondau=0 and slnhap=0 and slxuat=0");
                        ttb.execute_data("delete from " + xxx + ".ttb_tutructh where tondau=0 and slnhap=0 and slxuat=0");
                        Cursor = Cursors.Default;
                    }
                    else
                    {
                        return;
                    }
                }
                else if (iret == -1)
                {
                    return;
                }
                if (iNhomkho != 0 && !bKiemtra)
                {
                    if (!ttb.bKhoaso(iNhomkho, mMmyy) && ttb.get_kiemtra(mMmyy, iNhomkho, ngay.Text))
                    {
                        Cursor = Cursors.WaitCursor;
                        ttb.upd_kiemtra(mMmyy, iNhomkho, ngay.Text, iUserid);
                        ttb.upd_tonkho(iNhomkho, mMmyy);
                        Cursor = Cursors.Default;
                    }
                }
            }
            else
            {
                mUserid = LibTTB.AccessData.links_userid + LibTTB.AccessData.links_pass;
            }
            this.mExit = false;
            this.Close();
        }
Esempio n. 22
0
        private void get_data()
        {
            if (tu.Value > den.Value)
            {
                MessageBox.Show("Tháng không hợp lệ !", ttb.Msg);
                tu.Focus();
                return;
            }
            s_manhom = "";
            for (int i = 0; i < manhom.Items.Count; i++)
            {
                if (manhom.GetItemChecked(i))
                {
                    s_manhom += dtdmnhom.Rows[i]["id"].ToString() + ",";
                }
            }
            s_kho = "";
            string s_tenkho = "";

            for (int i = 0; i < kho.Items.Count; i++)
            {
                if (kho.GetItemChecked(i))
                {
                    s_kho    += dtdmkho.Rows[i]["id"].ToString() + ",";
                    s_tenkho += dtdmkho.Rows[i]["ten"].ToString() + ",";
                }
            }
            ds.Clear();
            dsxml.Clear();
            s_mmyy = tu.Value.ToString().PadLeft(2, '0') + yyyy.Value.ToString().PadLeft(4, '0').Substring(2, 2);
            s_tu   = tu.Value.ToString().PadLeft(2, '0');
            s_den  = den.Value.ToString().PadLeft(2, '0');
            s_yy   = yyyy.Value.ToString().PadLeft(4, '0').Substring(2, 2);
            int    y1 = int.Parse(yyyy.Value.ToString()), m1 = int.Parse(tu.Value.ToString());
            int    y2 = int.Parse(yyyy.Value.ToString()), m2 = int.Parse(den.Value.ToString());
            int    itu, iden;
            string mmyy = m1.ToString().PadLeft(2, '0') + y1.ToString().Substring(2, 2);

            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 (ttb.bMmyy(mmyy))
                    {
                        get_xuat(mmyy);
                        get_hoantra(mmyy);
                    }
                }
            }
            if (ds.Tables[0].Rows.Count == 0)
            {
                MessageBox.Show("Không có số liệu !", ttb.Msg);
                return;
            }
            get_sort();
            string    s_thoigian = ttb.title(tu.Value.ToString(), den.Value.ToString()) + " Năm " + yyyy.Value.ToString();
            frmReport f          = new frmReport(ttb, dsxml.Tables[0], "d_dasudung.rpt", s_thoigian, "", (manguon.SelectedIndex == -1)?"":"Nguồn :" + manguon.Text, (nhomcc.SelectedIndex == -1)?"":" Nhóm nhà cung cấp :" + nhomcc.Text, "PHIẾU XUẤT KHO", "", "", "", "", "");

            f.ShowDialog();
        }
Esempio n. 23
0
        private void butOk_Click(object sender, System.EventArgs e)
        {
            if (!kiemtra())
            {
                return;
            }
            s_mmyy = mm.Value.ToString().PadLeft(2, '0') + yyyy.Value.ToString().PadLeft(4, '0').Substring(2, 2);
            if (!ttb.bMmyy(s_mmyy))
            {
                MessageBox.Show(lan.Change_language_MessageText("Số liệu ") + nhom.Text + lan.Change_language_MessageText(" tháng ") + mm.Value.ToString() + "/" + yyyy.Value.ToString() + lan.Change_language_MessageText(" chưa tạo !"), ttb.Msg);
                mm.Focus();
                return;
            }
            i_nhom    = int.Parse(nhom.SelectedValue.ToString());
            Cursor    = Cursors.WaitCursor;
            s_manguon = ttb.get_data("select nguon from " + user + ".ttb_dmphieu where id=" + i_loai).Tables[0].Rows[0][0].ToString();
            s_makp    = ""; s_makho = "";
            s_ngay    = ngay.Text.Substring(0, 10);
            s_tenkp   = makp.Text;
            s_phieu   = phieu.Text;
            s_tennhom = nhom.Text;
            i_somay   = 1;
            i_buoi    = 0;
            i_makp    = int.Parse(makp.SelectedValue.ToString());
            if (i_loai == 2)
            {
                i_macstt = int.Parse(matutruc.SelectedValue.ToString());
            }
            else
            {
                i_macstt = 0;
            }
            i_phieu = int.Parse(phieu.SelectedValue.ToString());
            r       = ttb.getrowbyid(dtmakp, "id=" + i_makp);
            if (r != null)
            {
                s_makp = r["makp"].ToString();

                //DataRow r1 = m.getrowbyid(dtkp, "loai=1 and makp='" + s_makp + "'");//
                //if (r1 != null) s_makp = "";//neu la phong kham--> makp=""--> khong hoan tra duoc
                //
                i_somay = int.Parse(r["somay"].ToString());
            }
            for (int i = 0; i < makho.Items.Count; i++)
            {
                s_makho += dtkho.Rows[i]["id"].ToString() + ",";
            }
            dt = ttb.get_data("select a.id,a.makp,b.ten from " + user + s_mmyy + ".ttb_duyet a," + user + ".d_duockp b where a.makp=b.id and a.nhom=" + i_nhom + " and to_char(a.ngay,'dd/mm/yyyy')='" + ((s_ngay.Length > 10)?s_ngay.Substring(0, 10):s_ngay) + "'" + " and a.loai=" + i_loai + " and a.phieu=" + i_phieu + " and a.makhoa=" + i_makp).Tables[0];
            if (dt.Rows.Count != 0)
            {
                l_duyet = decimal.Parse(dt.Rows[0][0].ToString());
                if (i_loai == 2 && int.Parse(dt.Rows[0]["makp"].ToString()) != int.Parse(matutruc.SelectedValue.ToString()))
                {
                    MessageBox.Show(lan.Change_language_MessageText("Khoa :") + " " + makp.Text + lan.Change_language_MessageText(" ngày : ") + " " + ngay.Text.Substring(0, 10) + " " + lan.Change_language_MessageText("phiếu : ") + " " + phieu.Text + "\n" + lan.Change_language_MessageText("đã chọn tủ trực :") + " " + dt.Rows[0]["ten"].ToString(), ttb.Msg);
                    matutruc.SelectedValue = dt.Rows[0]["makp"].ToString();
                    matutruc.Focus();
                    return;
                }
            }
            else
            {
                l_duyet = 0;
            }

            if (i_benhnhan == 0 && s_makp == "")
            {
                s_makp = "xx";
            }
            r = ttb.getrowbyid(dtphieu, "id=" + i_phieu);
            if (r != null)
            {
                i_buoi = int.Parse(r["buoi"].ToString());
            }
            if (ttb.bKiemtra_duyet(i_nhom))
            {
                ttb.upd_tonkho(s_mmyy, i_nhom, 0);
            }
            Cursor = Cursors.Default;
            string ngayt = ttb.DateToString("dd/MM/yyyy", ttb.StringToDate("01/" + mm.Value.ToString().PadLeft(2, '0') + "/" + yyyy.Value.ToString().PadLeft(4, '0')).AddMonths(-1));
            string mmyyt = ttb.mmyy(ngayt);

            if (i_loai == 2)
            {
                if (ttb.bMmyy(mmyyt))
                {
                    sql  = "select a.* from " + user + mmyyt + ".ttb_xtutrucll a," + user + mmyyt + ".ttb_duyet b ";
                    sql += " where a.idduyet=b.id ";
                    sql += " and nhom=" + i_nhom + " and to_char(ngay,'dd/mm/yyyy')='" + s_ngay + "'";
                    sql += " and loai=" + i_loai + " and phieu=" + i_phieu + " and makhoa=" + i_makp;
                    if (ttb.get_data(sql).Tables[0].Rows.Count > 0)
                    {
                        MessageBox.Show(lan.Change_language_MessageText("Đã nhập trong tháng") + " " + mmyyt.Substring(0, 2) + lan.Change_language_MessageText(" năm 20") + mmyyt.Substring(2, 2), ttb.Msg);
                        mm.Value   = decimal.Parse(mmyyt.Substring(0, 2));
                        yyyy.Value = decimal.Parse("20" + mmyyt.Substring(2, 2));
                        mm.Focus();
                        return;
                    }
                }
            }
            else if (i_loai == 1)
            {
                if (ttb.bMmyy(mmyyt))
                {
                    sql  = "select a.* from " + user + mmyyt + ".ttb_dutrull a," + user + mmyyt + ".ttb_duyet b ";
                    sql += " where a.idduyet=b.id ";
                    sql += " and nhom=" + i_nhom + " and to_char(ngay,'dd/mm/yyyy')='" + s_ngay + "'";
                    sql += " and loai=" + i_loai + " and phieu=" + i_phieu + " and makhoa=" + i_makp;
                    if (ttb.get_data(sql).Tables[0].Rows.Count > 0)
                    {
                        MessageBox.Show(lan.Change_language_MessageText("Đã nhập trong tháng") + " " + mmyyt.Substring(0, 2) + " " + lan.Change_language_MessageText("năm 20") + mmyyt.Substring(2, 2), ttb.Msg);
                        mm.Value   = decimal.Parse(mmyyt.Substring(0, 2));
                        yyyy.Value = decimal.Parse("20" + mmyyt.Substring(2, 2));
                        mm.Focus();
                        return;
                    }
                }
            }
            ttb.close(); this.Close();
        }
Esempio n. 24
0
        private void get_data()
        {
            dsdn.Clear();
            d_cothue = 0; i_soct = 0;
            string so = "'";

            if (sohd.SelectedItems.Count > 0)
            {
                if (sohd.CheckedItems.Count == 0)
                {
                    for (int i = 0; i < sohd.Items.Count; i++)
                    {
                        sohd.SetItemCheckState(i, CheckState.Checked);
                    }
                }
                for (int i = 0; i < sohd.Items.Count; i++)
                {
                    if (sohd.GetItemChecked(i))
                    {
                        so += dtsohd.Rows[i]["sohd"].ToString().Trim() + "','";
                        i_soct++;
                    }
                }
            }
            string sql = "select a.sohd,to_char(a.ngayhd,'dd/mm/yyyy') as ngayhd,a.sophieu,to_char(a.ngaysp,'dd/mm/yyyy') as ngaysp,";

            sql += "sum(round(b.sotien+b.sotien*b.vat/100+b.cuocvc+b.chaythu," + i_thanhtien_le + ")) as sotien from xxx.ttb_nhapll a,xxx.ttb_nhapct b," + user + ".ttb_dmnx c where a.id=b.id and a.madv=c.id";
            sql += " and a.ngayhd between to_date('" + tu.Text + "','" + f_ngay + "') and to_date('" + den.Text + "','" + f_ngay + "')";
            sql += " and a.nhom=" + i_nhom + " and trim(c.ma)='" + madv.Text + "'";
            if (so.Length > 1)
            {
                sql += " and trim(a.sohd) in (" + so.Substring(0, so.Length - 2) + ")";
            }
            sql += " group by a.sohd,to_char(a.ngayhd,'dd/mm/yyyy'),a.sophieu,to_char(a.ngaysp,'dd/mm/yyyy')";
            DateTime dt1 = ttb.StringToDate(tu.Text.Substring(0, 10)).AddDays(-ttb.iNgaykiemke);
            DateTime dt2 = ttb.StringToDate(den.Text.Substring(0, 10)).AddDays(ttb.iNgaykiemke);
            int      y1 = dt1.Year, m1 = dt1.Month;
            int      y2 = dt2.Year, m2 = dt2.Month;
            int      itu, iden;
            DataRow  r1, r2;

            DataRow [] dr;
            string     mmyy = "", sql1;

            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 (ttb.bMmyy(mmyy))
                    {
                        sql1 = sql.Replace("xxx", user);
                        foreach (DataRow r in ttb.get_data(sql1).Tables[0].Rows)
                        {
                            r1 = ttb.getrowbyid(dsdn.Tables[0], "sohd='" + r["sohd"].ToString() + "' and ngayhd='" + r["ngayhd"].ToString() + "'");
                            if (r1 == null)
                            {
                                r2            = dsdn.Tables[0].NewRow();
                                r2["sohd"]    = r["sohd"].ToString();
                                r2["ngayhd"]  = r["ngayhd"].ToString();
                                r2["sophieu"] = i_soct.ToString();                              //r["sophieu"].ToString();
                                r2["ngaysp"]  = r["ngaysp"].ToString();
                                r2["sotien"]  = decimal.Parse(r["sotien"].ToString());
                                dsdn.Tables[0].Rows.Add(r2);
                            }
                            else
                            {
                                dr = dsdn.Tables[0].Select("sohd='" + r["sohd"].ToString() + "' and ngayhd='" + r["ngayhd"].ToString() + "'");
                                if (dr.Length > 0)
                                {
                                    dr[0]["sotien"] = decimal.Parse(dr[0]["sotien"].ToString()) + decimal.Parse(r["sotien"].ToString());
                                }
                            }
                            d_cothue += decimal.Parse(r["sotien"].ToString());
                        }
                    }
                }
            }
        }