Пример #1
0
        //Cach 1
        private void CapNhatSLVatTuKhoVer1(int ID_QuyetDinh, byte trangthai)
        {
            clsQD_NhapVatTu_ChiTiet clsChiTiet = new clsQD_NhapVatTu_ChiTiet();
            clsKho_VatTu            clsKVT     = new clsKho_VatTu();
            DataTable dt = clsChiTiet.SelectAllW_ID_QuyetDinh(ID_QuyetDinh);

            foreach (DataRow dr in dt.Rows)
            {
                clsKVT.ID_Kho   = Convert.ToInt32(dr["ID_Kho"]);
                clsKVT.ID_VatTu = Convert.ToInt32(dr["ID_VatTu"]);
                bool bInsert = clsKVT.SelectOne().Rows.Count == 0;

                if (trangthai == 5)
                {
                    if (bInsert)
                    {
                        clsKVT.SoLuong = Convert.ToInt32(dr["SoLuong"]);
                        clsKVT.Insert();
                    }
                    else
                    {
                        clsKVT.SoLuong = clsKVT.SoLuong + Convert.ToInt32(dr["SoLuong"]);
                        clsKVT.Update();
                    }
                }
                else if (trangthai == 3)
                {
                    clsKVT.SoLuong = clsKVT.SoLuong - Convert.ToInt32(dr["SoLuong"]);
                    clsKVT.Update();
                }
            }
        }
Пример #2
0
        private void Loadfg()
        {
            fg.Tag = 0;
            fg.BeginUpdate();
            clsQD_NhapVatTu_ChiTiet cls = new clsQD_NhapVatTu_ChiTiet();
            Byte loai = 0; //dang xem

            if (!btnCapNhat.Visible)
            {
                loai = 1;                      //dang cap nhat
            }
            if (m_byTrangthai == 1 || m_byTrangthai == 5)
            {
                loai = 0;
            }
            int iSTT = 1;

            fg.Rows.Count = fg.Rows.Fixed;
            DataTable dt = cls.Select_DS_VatTu(m_iID_QuyetDinh, m_iID_NhaCungCap, loai);

            foreach (DataRow dr in dt.DefaultView.ToTable().Rows)
            {
                Row fgRow = fg.Rows.Add();
                fgRow["STT"] = iSTT;
                iSTT++;
                fgRow["ID_QuyetDinh"] = dr["ID_QuyetDinh"];
                fgRow["Chon"]         = dr["Chon"];
                fgRow["ID_VatTu"]     = dr["ID_VatTu"];
                fgRow["Ten_VatTu"]    = dr["Ten_VatTu"];
                fgRow["ID_Kho"]       = dr["ID_Kho"];
                fgRow["SoLuong"]      = dr["SoLuong"];
            }

            clsDM_Kho clsKho = new clsDM_Kho();
            DataTable dtKho  = clsKho.SelectAll();

            dtKho.DefaultView.RowFilter = "TonTai = 1";
            ListDictionary datamap = new ListDictionary();

            for (int i = 0; i <= dtKho.DefaultView.ToTable().Rows.Count - 1; i++)
            {
                datamap.Add(dtKho.Rows[i][0], dtKho.Rows[i][1]);
            }
            fg.Cols["ID_Kho"].DataMap = datamap;

            fg.Row = -1;
            fg.AutoSizeRows();
            fg.AutoSizeCols();
            fg.EndUpdate();
            fg.Tag = 1;
        }
Пример #3
0
        private void SaveDataChiTiet(int ID_QuyetDinh)
        {
            //Save data chi tiet
            clsQD_NhapVatTu_ChiTiet clsChiTiet = new clsQD_NhapVatTu_ChiTiet();

            clsChiTiet.ID_QuyetDinh = Convert.ToInt32(ID_QuyetDinh);
            clsChiTiet.DeleteWID_QuyetDinhLogic();
            for (int i = fgChiTiet.Rows.Fixed; i < fgChiTiet.Rows.Count; i++)
            {
                if (fgChiTiet.GetBoolValue(i, "Chon"))
                {
                    clsChiTiet.ID_VatTu = fgChiTiet.GetIntValue(i, "ID_VatTu");
                    clsChiTiet.ID_Kho   = fgChiTiet.GetIntValue(i, "ID_Kho");
                    clsChiTiet.SoLuong  = fgChiTiet.GetIntValue(i, "SoLuong");
                    clsChiTiet.Insert();
                }
            }
        }
Пример #4
0
        //Cach 3
        private void CapNhatSLVatTuKhoVer3(int ID_QuyetDinh, byte trangthai)
        {
            clsQD_NhapVatTu_ChiTiet clsChiTiet = new clsQD_NhapVatTu_ChiTiet();
            clsKho_VatTu            clsKVT     = new clsKho_VatTu();

            DataTable dt = clsChiTiet.SelectAllW_ID_QuyetDinh(ID_QuyetDinh);

            foreach (DataRow dr in dt.Rows)
            {
                if (trangthai == 5)
                {
                    clsKVT.Update_SoLuongVer3(Convert.ToInt32(dr["ID_Kho"]), Convert.ToInt32(dr["ID_VatTu"]), Convert.ToInt32(dr["SoLuong"]));
                }
                else if (trangthai == 3)
                {
                    clsKVT.Update_SoLuongVer3(Convert.ToInt32(dr["ID_Kho"]), Convert.ToInt32(dr["ID_VatTu"]), (-1) * Convert.ToInt32(dr["SoLuong"]));
                }
            }
        }
Пример #5
0
        private void btnLuu_Click(object sender, EventArgs e)
        {
            if (!IsValid())
            {
                return;
            }
            clsQD_NhapVatTu_ChiTiet cls = new clsQD_NhapVatTu_ChiTiet();

            cls.ID_QuyetDinh = m_iID_QuyetDinh;
            cls.DeleteWID_QuyetDinhLogic();
            for (int i = fg.Rows.Fixed; i < fg.Rows.Count; i++)
            {
                if (fg.GetBoolValue(i, "Chon"))
                {
                    cls.ID_VatTu = fg.GetIntValue(i, "ID_VatTu");
                    cls.ID_Kho   = fg.GetIntValue(i, "ID_Kho");
                    cls.SoLuong  = fg.GetIntValue(i, "SoLuong");
                    cls.Insert();
                }
            }
            BaseMessages.ShowInformationMessage("Cập nhật thành công!");
            LockEdit(true);
            Loadfg();
        }
Пример #6
0
        private void LoadfgChiTiet(int ID_QuyetDinh, int ID_NhaCungCap)
        {
            //if (fgQD.Row < fgQD.Rows.Fixed)
            //{
            //    return;
            //}
            var fg = fgChiTiet;

            fg.Tag = 0;
            fg.BeginUpdate();
            int iSTT = 1;

            fg.Rows.Count = fg.Rows.Fixed;
            if (ID_QuyetDinh != 0) //Xem/Sua
            {
                clsQD_NhapVatTu_ChiTiet cls = new clsQD_NhapVatTu_ChiTiet();
                Byte byLoai = 0; //dang xem
                if (!btnSua.Visible)
                {
                    byLoai = 1; //dang cap nhat
                }
                DataTable dt = cls.Select_DS_VatTuVer2(ID_QuyetDinh, ID_NhaCungCap, byLoai);
                foreach (DataRow dr in dt.Rows)
                {
                    Row fgRow = fg.Rows.Add();
                    fgRow["STT"] = iSTT;
                    iSTT++;
                    fgRow["ID_QuyetDinh"] = dr["ID_QuyetDinh"];
                    fgRow["Chon"]         = dr["Chon"];
                    fgRow["ID_VatTu"]     = dr["ID_VatTu"];
                    fgRow["Ten_VatTu"]    = dr["Ten_VatTu"];
                    fgRow["ID_Kho"]       = dr["ID_Kho"];
                    fgRow["Ten_Kho"]      = dr["Ten_Kho"];
                    fgRow["SoLuong"]      = dr["SoLuong"];
                }
            }
            else //ID_QuyetDinh = 0, Them moi' QD
            {
                clsDM_VatTu cls = new clsDM_VatTu();
                DataTable   dt  = cls.SelectVatTuWithID_NhaCungCap(ID_NhaCungCap);
                foreach (DataRow dr in dt.Rows)
                {
                    Row fgRow = fg.Rows.Add();
                    fgRow["STT"] = iSTT;
                    iSTT++;
                    fgRow["Chon"]      = false;
                    fgRow["ID_VatTu"]  = dr["ID_VatTu"];
                    fgRow["Ten_VatTu"] = dr["Ten_VatTu"];
                    fgRow["ID_Kho"]    = dr["ID_Kho"];
                    fgRow["Ten_Kho"]   = dr["Ten_Kho"];
                }
            }
            //
            //Tao combobox chon. Kho
            //
            //clsDM_Kho clsKho = new clsDM_Kho();
            //DataTable dtKho = clsKho.SelectAll();
            //dtKho.DefaultView.RowFilter = "TonTai = 1";
            //ListDictionary datamap = new ListDictionary();
            //for (int i = 0; i <= dtKho.DefaultView.ToTable().Rows.Count - 1; i++)
            //{
            //    datamap.Add(dtKho.Rows[i][0], dtKho.Rows[i][1]);
            //}
            //fg.Cols["ID_Kho"].DataMap = datamap;
            //
            //
            fg.Row = -1;
            fg.AutoSizeRows();
            fg.EndUpdate();
            fg.Tag = 1;
        }