Esempio n. 1
0
        void EditDtNh(enuEdit enuNew_Edit)
        {
            if (bdsDoiTuongNh.Position < 0 && enuNew_Edit == enuEdit.Edit)
            {
                return;
            }

            //Copy hang hien tai
            if (bdsDoiTuongNh.Position >= 0)
            {
                Common.CopyDataRow(((DataRowView)bdsDoiTuongNh.Current).Row, ref drCurrentDtNh);
            }
            else
            {
                drCurrentDtNh = dtDoiTuongNh.NewRow();
            }

            frmDoiTuongNh_Edit frmEdit = new frmDoiTuongNh_Edit();

            frmEdit.Load(enuNew_Edit, drCurrentDtNh);

            //Accept
            if (frmEdit.isAccept)
            {
                htHistory["DIEN_GIAI"] = "Danh mục nhóm đối tượng";
                strTableName           = "LIDOITUONGNH";
                strCode = "MA_NH_DT";
                strName = "TEN_NH_DT";
                //Cập nhật History
                DataRow drHistory = drCurrentDtNh;
                htHistory["CODE"] = drHistory[strCode];
                htHistory["NAME"] = drHistory[strName];

                if (enuNew_Edit == enuEdit.New)
                {
                    htHistory["UPDATE_TYPE"] = "N";
                    UpdateHistory();
                }
                else if (enuNew_Edit == enuEdit.Edit && ((string)drHistory[strCode] != (string)((DataRowView)bdsDoiTuongNh.Current)[strCode] || (string)drHistory[strName] != (string)((DataRowView)bdsDoiTuongNh.Current)[strName]))
                {
                    htHistory["UPDATE_TYPE"] = "E";
                    htHistory["CODE_OLD"]    = ((DataRowView)bdsDoiTuongNh.Current)[strCode];
                    htHistory["NAME_OLD"]    = ((DataRowView)bdsDoiTuongNh.Current)[strName];
                    UpdateHistory();
                }
                //Cập nhật dữ liệu chứng từ
                if (enuNew_Edit == enuEdit.New)
                {
                    if (bdsDoiTuongNh.Position >= 0)
                    {
                        dtDoiTuongNh.ImportRow(drCurrentDtNh);
                    }
                    else
                    {
                        dtDoiTuongNh.Rows.Add(drCurrentDtNh);
                    }

                    bdsDoiTuongNh.Position = bdsDoiTuongNh.Find("Ma_Nh_Dt", drCurrentDtNh["Ma_Nh_Dt"]);
                }
                else
                {
                    Common.CopyDataRow(drCurrentDtNh, ((DataRowView)bdsDoiTuongNh.Current).Row);
                }

                dtDoiTuongNh.AcceptChanges();
            }
            else
            {
                dtDoiTuongNh.RejectChanges();
            }
        }
Esempio n. 2
0
        public override void Edit(enuEdit enuNew_Edit)
        {
            if (bdsDoiTuongNh.Position < 0 && enuNew_Edit == enuEdit.Edit)
            {
                return;
            }

            //Copy hang hien tai
            if (bdsDoiTuongNh.Position >= 0)
            {
                Common.CopyDataRow(((DataRowView)bdsDoiTuongNh.Current).Row, ref drCurrent);
            }
            else
            {
                drCurrent = dtDoiTuongNh.NewRow();
            }

            frmDoiTuongNh_Edit frmEdit = new frmDoiTuongNh_Edit();

            frmEdit.Load(enuNew_Edit, drCurrent);

            //Accept
            if (frmEdit.isAccept)
            {
                //Cập nhật History
                DataRow drHistory = drCurrent;
                htHistory["CODE"] = drHistory[strCode];
                htHistory["NAME"] = drHistory[strName];

                if (enuNew_Edit == enuEdit.New)
                {
                    htHistory["UPDATE_TYPE"] = "N";
                    UpdateHistory();
                }
                else if (enuNew_Edit == enuEdit.Edit && ((string)drHistory[strCode] != (string)((DataRowView)bdsDoiTuongNh.Current)[strCode] || (string)drHistory[strName] != (string)((DataRowView)bdsDoiTuongNh.Current)[strName]))
                {
                    htHistory["UPDATE_TYPE"] = "E";
                    htHistory["CODE_OLD"]    = ((DataRowView)bdsDoiTuongNh.Current)[strCode];
                    htHistory["NAME_OLD"]    = ((DataRowView)bdsDoiTuongNh.Current)[strName];
                    UpdateHistory();
                }
                //Cập nhật dữ liệu chứng từ
                if (enuNew_Edit == enuEdit.New)
                {
                    if (bdsDoiTuongNh.Position >= 0)
                    {
                        dtDoiTuongNh.ImportRow(drCurrent);
                    }
                    else
                    {
                        dtDoiTuongNh.Rows.Add(drCurrent);
                    }

                    bdsDoiTuongNh.Position = bdsDoiTuongNh.Find("Ma_Nh_Dt", drCurrent["Ma_Nh_Dt"]);
                }
                else
                {
                    Common.CopyDataRow(drCurrent, ((DataRowView)bdsDoiTuongNh.Current).Row);
                }

                dtDoiTuongNh.AcceptChanges();
            }
            else
            {
                dtDoiTuongNh.RejectChanges();
            }
        }