Exemplo n.º 1
0
        private void SaveData()
        {
            // check xem có trong db chưa?
            string   SupplierID = txtSupplierId.Text.Trim();
            Supplier pro        = new Supplier();

            pro = supBLL.GetSupplierWithID(SupplierID);

            supSea = new Supplier();

            supSea.SupplierName    = txtName.Text;
            supSea.SupplierAddress = txtAddress.Text;
            supSea.SupplierPhone   = txtPhone.Text;
            supSea.SupplierEmail   = txtEmail.Text;
            supSea.SupplierWebsite = txtSite.Text;


            if (pro != null)
            {// Cập nhật
                if (CustomMessageBox.MessageBox.ShowCustomMessageBox(Common.clsLanguages.GetResource("CommonCodeUpdate"),
                                                                     Common.clsLanguages.GetResource("Information"),
                                                                     Common.Config.CUSTOM_MESSAGEBOX_ICON.Information,
                                                                     Common.Config.CUSTOM_MESSAGEBOX_BUTTON.YESNO) == DialogResult.Yes)
                {
                    supSea.SupplierId = SupplierID;
                    int i = supBLL.Update(supSea);
                    if (i == 1)
                    {
                        lblTB1.Text = Common.clsLanguages.GetResource("UpdateSuccess1");
                    }
                    else
                    {
                        lblTB1.Text = Common.clsLanguages.GetResource("UpdateNoSuccess1");
                    }
                }
            }
            else
            {// Thêm mới
                if (CustomMessageBox.MessageBox.ShowCustomMessageBox(Common.clsLanguages.GetResource("CommonCodeCreate"),
                                                                     Common.clsLanguages.GetResource("Information"),
                                                                     Common.Config.CUSTOM_MESSAGEBOX_ICON.Information,
                                                                     Common.Config.CUSTOM_MESSAGEBOX_BUTTON.YESNO) == DialogResult.Yes)
                {
                    SupplierID        = supBLL.CreateSupplierId();
                    supSea.SupplierId = SupplierID;

                    int i = supBLL.Insert(supSea);
                    if (i == 1)
                    {
                        lblTB1.Text        = Common.clsLanguages.GetResource("InsertSuccess1");
                        txtSupplierId.Text = SupplierID;
                    }
                    else
                    {
                        lblTB1.Text = Common.clsLanguages.GetResource("InsertNoSuccess1");
                    }
                }
            }

            SearchProducts(1);
        }