public void SaveCustomer(frmCustomerDetail frmCustomerDetail)
 {
     try
     {
         string name    = frmCustomerDetail.getCustomerName().Text;
         string phone   = frmCustomerDetail.getCustomerPhone().Text;
         string address = frmCustomerDetail.getAddress().Text;
         bool   isValid = checkCustomerField(name, phone, address);
         if (isValid)
         {
             TblCustomerDTO dto = new TblCustomerDTO()
             {
                 idCustomer = frmCustomerDetail.getCustomerID(),
                 name       = name,
                 phone      = phone,
                 address    = address
             };
             if (frmCustomerDetail.isAddNew())
             {
                 customerModel.addCustomer(dto);
                 LoadCustomers();
             }
             else
             {
                 customerModel.updateCustomer(dto);
                 LoadCustomers();
             }
             MessageBox.Show(MessageUtil.SAVE_SUCCESS);
         }
     }
     catch (Exception)
     {
         MessageBox.Show(MessageUtil.ERROR + " Save Customer!");
     }
 }
Ejemplo n.º 2
0
        /// <summary>
        /// 点击查看供应商详情
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void plRow_Press(object sender, EventArgs e)
        {
            frmCustomerDetail frmCusDetail = new frmCustomerDetail();

            frmCusDetail.vId      = Convert.ToInt32(lblName.BindDataValue);
            frmCusDetail.unitType = ((frmCustomer)Form).unitType;
            Form.Show(frmCusDetail, (MobileForm sender1, object args) => {
                ((frmCustomer)Form).Bind();
            });
        }
        public void UpdateCustomer()
        {
            frmCustomerDetail customerDetail = new frmCustomerDetail(false, form);

            //get customer detail from frmSaleManager
            customerDetail.setCustomerId(form.getCustomerId().Text);
            customerDetail.getCustomerName().Text  = form.getCustomerName().Text;
            customerDetail.getCustomerPhone().Text = form.getCustomerPhone().Text;
            customerDetail.getAddress().Text       = form.getCustomerAddress().Text;

            //show customerDetail form
            DialogResult r = customerDetail.ShowDialog();
        }
 public void AddCustomer()
 {
     frmCustomerDetail customerDetail = new frmCustomerDetail(true, form);
     DialogResult      r = customerDetail.ShowDialog();
 }