Esempio n. 1
0
        public override void btn_Save_Click(object sender, EventArgs e)
        {
            if (tbx_Name.Text != "")
            {
                customer = new BDCustomer();
                BDCustomerService customerService = new BDCustomerService();
                if (CustomerID == null)//new customer
                {
                    customer.CustomerCode = tbx_Code.Text;
                    customer.CustomerName = tbx_Name.Text;
                    customer.Address      = tbx_Address.Text;
                    customer.Phone1       = tbx_Pone1.Text;
                    customer.Phone2       = tbx_phone2.Text;
                    customer.Mobile1      = tbx_Mobile1.Text;
                    customer.Mobile2      = tbx_Mobile2.Text;
                    customer.Email        = tbx_Email.Text;
                    customer.IsActive     = chk_IsActive.Checked;
                    customer.Debit        = 0;
                    customer.Credit       = 0;
                    customerService.Insert(customer);
                    MessageBox.Show("تم الحفظ بنجاح");
                }
                else
                {
                    BDCustomerPrimaryKey pk = new BDCustomerPrimaryKey();
                    pk.CustomerID         = CustomerID;
                    customer              = customerService.SelectOne(pk);
                    customer.CustomerCode = tbx_Code.Text;
                    customer.CustomerName = tbx_Name.Text;
                    customer.Address      = tbx_Address.Text;
                    customer.Phone1       = tbx_Pone1.Text;
                    customer.Phone2       = tbx_phone2.Text;
                    customer.Mobile1      = tbx_Mobile1.Text;
                    customer.Mobile2      = tbx_Mobile2.Text;
                    customer.Email        = tbx_Email.Text;
                    customer.IsActive     = chk_IsActive.Checked;
                    customerService.Update(customer);
                    MessageBox.Show("تم التعديل بنجاح");
                }
            }
            else
            {
                MessageBox.Show("لابد من ادخال إسم العميل");
            }

            this.Close();
        }