Exemple #1
0
        public override bool PerformSave()
        {
            try
            {
                bool success = false;
                itvs.Windows.Public.OrderHashtable hashtableControls = new  itvs.Windows.Public.OrderHashtable();
                hashtableControls.Add(txtMa_Table, lblMa_Table.Text);
                hashtableControls.Add(txtTen_Table, lblTen_Table.Text);
                hashtableControls.Add(lookUp_Cuahang_Ban, lblKho.Text);

                System.Collections.Hashtable htbTen_Table = new System.Collections.Hashtable();
                htbTen_Table.Add(txtTen_Table, lblTen_Table.Text);

                if (!itvs.Windows.MdiUtils.Validator.CheckNullFields(hashtableControls))
                {
                    return(false);
                }

                if (this.FormState == itvs.Windows.Forms.FormState.Add)
                {
                    if (!itvs.Windows.MdiUtils.Validator.CheckExistValues(htbTen_Table, ds_Collection, "Ten_Table"))
                    {
                        return(false);
                    }
                    success = (bool)this.InsertObject();
                }
                else if (this.FormState == itvs.Windows.Forms.FormState.Edit)
                {
                    DataSet _ds = itvs.Windows.MdiUtils.Validator.datasetFillter(ds_Collection, "Id_Table = " + gridView1.GetFocusedRowCellValue("Id_Table"));
                    if (!itvs.Windows.MdiUtils.Validator.CheckExistValues(htbTen_Table, _ds, "Ten_Table"))
                    {
                        return(false);
                    }
                    success = (bool)this.UpdateObject();
                }

                if (success)
                {
                    //DataSet ds_Bar_Dm_Table_Vitri = objMasterService.Get_All_ViTri_Dm_Bar_Table();
                    //if (System.IO.File.Exists(xml_BAR_DM_TABLE_VITRI))
                    //    ds_Bar_Dm_Table_Vitri.WriteXml(xml_BAR_DM_TABLE_VITRI, XmlWriteMode.WriteSchema);
                    this.DisplayInfo();
                }
                return(success);
            }
            catch (Exception ex)
            {
                if (ex.ToString().IndexOf("exists") != -1)
                {
                    itvs.Windows.Forms.UserMessage.Show("SYS_ALREADY_EXIST", new string[] { lblMa_Table.Text, lblMa_Table.Text });
                }
                return(false);
            }
        }
Exemple #2
0
        public override bool PerformSaveChanges()
        {
            itvs.Windows.Public.OrderHashtable hashtableControls = new  itvs.Windows.Public.OrderHashtable();
            hashtableControls.Add(gridView1.Columns["Ma_Table"], "");
            hashtableControls.Add(gridView1.Columns["Ten_Table"], "");
            hashtableControls.Add(gridView1.Columns["Id_Khuvuc"], "");
            if (!itvs.Windows.MdiUtils.Validator.CheckNullGrid(hashtableControls, gridView1))
            {
                return(false);
            }

            System.Collections.Hashtable htbTen_Table = new System.Collections.Hashtable();
            htbTen_Table.Add(gridView1.Columns["Ten_Table"], "");
            if (!itvs.Windows.MdiUtils.Validator.CheckExistGrid(htbTen_Table, gridView1))
            {
                return(false);
            }
            try
            {
                dgbar_Dm_Table.EmbeddedNavigator.Buttons.DoClick(dgbar_Dm_Table.EmbeddedNavigator.Buttons.EndEdit);
                ds_Collection.Tables[0].Columns["Ma_Table"].Unique = true;
                objMasterService.Update_Bar_Dm_Table_Collection(this.ds_Collection);
                //DataSet ds_Bar_Dm_Table_Vitri = objMasterService.Get_All_ViTri_Dm_Bar_Table();
                //if (System.IO.File.Exists(xml_BAR_DM_TABLE_VITRI))
                //    ds_Bar_Dm_Table_Vitri.WriteXml(xml_BAR_DM_TABLE_VITRI, XmlWriteMode.WriteSchema);
            }
            catch (Exception ex)
            {
                if (ex.ToString().IndexOf("Unique") != -1)
                {
                    itvs.Windows.Forms.UserMessage.Show("SYS_ALREADY_EXIST", new string[] { lblMa_Table.Text, lblMa_Table.Text });
                    return(false);
                }
            }
            this.DisplayInfo();
            return(true);
        }
Exemple #3
0
        public override bool PerformSaveChanges()
        {
            dsSys_Lognotify          = objMasterService.Get_Sys_Lognotify_SelectLastChange_OfTables("[ware_dm_hanghoa_ban]");
            dtlc_ware_dm_hanghoa_ban = GetLastChange_FrmLognotify("ware_dm_hanghoa_ban");

            if (!System.IO.File.Exists(xml_WARE_DM_HANGHOA_BAN) ||
                DateTime.Compare(dtlc_ware_dm_hanghoa_ban, System.IO.File.GetLastWriteTime(xml_WARE_DM_HANGHOA_BAN)) > 0)
            {
                ds_All_Hanghoa_Ban = objMasterService.Get_All_Ware_Dm_Hanghoa_Ban();
                ds_All_Hanghoa_Ban.WriteXml(xml_WARE_DM_HANGHOA_BAN, XmlWriteMode.WriteSchema);
            }
            else
            {
                ds_All_Hanghoa_Ban = new DataSet();
                ds_All_Hanghoa_Ban.ReadXml(xml_WARE_DM_HANGHOA_BAN);
            }

            this.DoClickEndEdit(dgware_Dm_Hanghoa_Ban);
            itvs.Windows.Public.OrderHashtable hashtableControls = new  itvs.Windows.Public.OrderHashtable();
            hashtableControls.Add(gridView1.Columns["Ma_Hanghoa_Ban"], "");
            hashtableControls.Add(gridView1.Columns["Ten_Hanghoa_Ban"], "");
            hashtableControls.Add(gridView1.Columns["Id_Donvitinh"], "");
            hashtableControls.Add(gridView1.Columns["Barcode_Txt"], "");

            if (!itvs.Windows.MdiUtils.Validator.CheckNullGrid(hashtableControls, gridView1))
            {
                return(false);
            }

            int focus = gridView1.FocusedRowHandle;

            if (FormState == itvs.Windows.Forms.FormState.Add)
            {
                System.Collections.Hashtable htbBarCode = new System.Collections.Hashtable();
                htbBarCode.Add(gridView1.Columns["Barcode_Txt"], "");
                if (!itvs.Windows.MdiUtils.Validator.CheckExistGrid(htbBarCode, gridView1))
                {
                    return(false);
                }
            }
            hashtableControls.Remove(gridView1.Columns["Id_Donvitinh"]);
            hashtableControls.Remove(gridView1.Columns["Ten_Hanghoa_Ban"]);

            if (!itvs.Windows.MdiUtils.Validator.CheckExistGrid(hashtableControls, gridView1))
            {
                gridView1.FocusedRowHandle = focus;
                return(false);
            }
            DataRow[] dtr    = null;
            DataRow[] dtr_Id = null;
            for (int i = 0; i < gridView1.RowCount; i++)
            {
                if (gridView1.GetDataRow(i).RowState == DataRowState.Modified)
                {
                    dtr_Id = ds_All_Hanghoa_Ban.Tables[0].Select("Id_Hanghoa_Ban = '" + gridView1.GetRowCellValue(i, gridView1.Columns["Id_Hanghoa_Ban"]) + "'");
                    if (!dtr_Id[0]["Ma_Hanghoa_Ban"].Equals(gridView1.GetRowCellValue(i, gridView1.Columns["Ma_Hanghoa_Ban"])))
                    {
                        dtr = ds_All_Hanghoa_Ban.Tables[0].Select("Ma_Hanghoa_Ban = '" + gridView1.GetRowCellValue(i, gridView1.Columns["Ma_Hanghoa_Ban"]) + "'");
                        if (dtr.Length >= 1)
                        {
                            itvs.Windows.Forms.MessageDialog.Show("Mã hàng " + gridView1.GetRowCellValue(i, gridView1.Columns["Ma_Hanghoa_Ban"]) + " đã tồn tại, nhập lại Mã hàng hóa");
                            return(false);
                        }
                    }
                }
                if (gridView1.GetDataRow(i).RowState == DataRowState.Added)
                {
                    dtr = ds_All_Hanghoa_Ban.Tables[0].Select("Ma_Hanghoa_Ban = '" + gridView1.GetRowCellValue(i, gridView1.Columns["Ma_Hanghoa_Ban"]) + "'");
                    if (dtr.Length >= 1)
                    {
                        itvs.Windows.Forms.MessageDialog.Show("Mã hàng " + gridView1.GetRowCellValue(i, gridView1.Columns["Ma_Hanghoa_Ban"]) + " đã tồn tại, nhập lại Mã hàng hóa");
                        return(false);
                    }
                }
            }
            try
            {
                //dgware_Dm_Hanghoa_Ban.EmbeddedNavigator.Buttons.EndEdit.DoClick();
                //ds_Collection.Tables[0].Columns["Ma_Hanghoa_Ban"].Unique = true;
                //ds_Collection.Tables[0].Columns["Ten_Hanghoa_Ban"].Unique = true;
                objMasterService.Update_Ware_Dm_Hanghoa_Ban_Collection(this.ds_Collection);
            }
            catch (Exception ex)
            {
                if (ex.ToString().IndexOf("Unique") != -1)
                {
                    if (ex.ToString().IndexOf("Ma_Hanghoa_Ban") != -1)
                    {
                        itvs.Windows.Forms.UserMessage.Show("SYS_ALREADY_EXIST", new string[] { lblMa_Hanghoa_Ban.Text, lblMa_Hanghoa_Ban.Text.ToLower() });
                    }
                    //else if (ex.ToString().IndexOf("Ten_Hanghoa_Ban") != -1)
                    //     itvs.Windows.Forms.UserMessage.Show("SYS_ALREADY_EXIST", new string[] { lblTen_Hanghoa_Ban.Text, lblTen_Hanghoa_Ban.Text.ToLower() });
                    return(false);
                }
                //MessageBox.Show(ex.ToString());
            }
            this.DisplayInfo2();
            return(true);
        }