Ejemplo n.º 1
0
        public EditCustomerForm(Customer customer)
        {
            InitializeComponent();
            this.customer = customer;
            bSave.DialogResult = DialogResult.OK;
            bCancel.DialogResult = DialogResult.Cancel;
            tName.Text = customer.FirstName;
            tLastName.Text = customer.LastName;
            tPhoneNumber.Text = customer.PhoneNumber;
            tDescription.Text = customer.Description;
            if (customer.Gender.Value)
            {
                rWoman.Checked = true;

            }
            else
            {
                rMan.Checked = true;
            }
        }
 public void updateCustomer(Customer c)
 {
     entities.Customers.Attach(c);
     entities.Entry(c).State = EntityState.Modified;
     entities.SaveChanges();
 }
 public void addCustomer(Customer c)
 {
     entities.Customers.Add(c);
     entities.SaveChanges();
 }
Ejemplo n.º 4
0
        private void bSave_Click(object sender, EventArgs e)
        {
            Customer c = new Customer();
            c.Id = customer.Id;
            c.CreatedDate = customer.CreatedDate;
            c.FirstName = tName.Text;
            c.LastName = tLastName.Text;
            c.PhoneNumber = tPhoneNumber.Text;
            c.Description = tDescription.Text;
            if (rWoman.Checked == true)
            {
                c.Gender = true;
            }
            else
            {
                c.Gender = false;
            }

            repository.updateCustomer(c);
        }
Ejemplo n.º 5
0
        private void bSave_Click(object sender, EventArgs e)
        {
            Customer customer = new Customer();
            CustomerRepository repository = new CustomerRepository();
            if (String.IsNullOrWhiteSpace(tName.Text) || String.IsNullOrWhiteSpace(tLastName.Text) || String.IsNullOrWhiteSpace(tPhoneNumber.Text))
            {
                MessageBox.Show("اطلاعات کامل وارد نشده است");
                return;
            }
            PersianDateFormatter pdf = new PersianDateFormatter();
            customer.CreatedDate = pdf.getDateInteger(DateTime.Now);
            customer.FirstName = tName.Text;
            customer.LastName = tLastName.Text;
            customer.PhoneNumber = tPhoneNumber.Text;
            if (rWoman.Checked)
            {
                customer.Gender = true;
            }
            else
            {
                customer.Gender = false;
            }

            if (!String.IsNullOrWhiteSpace(tDescription.Text))
            {
                customer.Description = tDescription.Text;
            }

            repository.addCustomer(customer);
            //MessageBox.Show("با موفقیت اضافه شد");
        }