コード例 #1
0
ファイル: Customer.cs プロジェクト: rehman922/VIRETAIL
 void DoSave(string option)
 {
     if (ValidateCustomer()) return;
     var bl = new BlCustomer();
     var newrow =(DsMaster.CUSTOMERRow) new DsMaster().CUSTOMER.NewRow();
     newrow.CUSTNO = _customerno;
     newrow.CUSTOMERTYPE = int.Parse(customertype.EditValue.ToString());
     newrow.CUSTCOMP = custcomp.Text;
     newrow.CUSTOMERNAME = customername.Text;
     newrow.CUSTOMERID = custmobile.Text;
     newrow.EMAIL = custemail.Text;
     newrow.PHONE = custphone.Text;
     newrow.Mobile = custmobile.Text;
     newrow.NOTE = custnote.Text;
     newrow.FIXDISC = custfixdisc.Checked;
     newrow.PAYTYPE = comboBoxEdit1.SelectedIndex;
     if(customertype.EditValue.ToString() =="0")
         newrow.MEMBERNO = int.Parse(txtmemno.EditValue.ToString());
     if (custfixdiscperc.EditValue!=null)
         newrow.FIXDISCAMTPER = decimal.Parse(custfixdiscperc.EditValue.ToString());
     if (iNSURANCEDISCBindingSource.Count > 0 && customertype.EditValue.ToString() == "1")
     {
         bl.InsurancediscDataTable = dsMaster1.INSURANCEDISC;
     }
     bl.CustomerRow = newrow;
     try
     {
         var retval = bl.DoSave();
         if (retval == "1")
         {
             _customerno = bl.Customerno;
             XtraMessageBox.Show("Data Saved", "POS", MessageBoxButtons.OK, MessageBoxIcon.Information);
             if (iNSURANCEDISCBindingSource.Count > 0)
             {
                 //var addedRows = from row in dsMaster1.INSURANCEDISC
                 //    where row.RowState == DataRowState.Added  select row;
                 //foreach (var row in addedRows.ToArray())
                 //{row.Delete();} dsMaster1.Merge(COMMON.ClsGetData.GetInsuranceByCust(_customerno));
                 //dsMaster1.AcceptChanges();
             }
             if(option=="1")
             {Dispose(); }
             if (option == "2")
             {DoNew();}
             SetNavigation();
         }
         else
         {
             XtraMessageBox.Show(retval, "POS", MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
     }
     catch(Exception ex)
     {
         XtraMessageBox.Show(ex.ToString(), "POS", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }