Beispiel #1
0
 protected override bool Save()
 {
     try
     {
         this.Cursor = Cursors.WaitCursor;
         if (string.IsNullOrEmpty(txtVendorName.Text.Trim()))
         {
             MessageBox.Show(clsTranslate.TranslateString("vendor name") + clsTranslate.TranslateString(" can not be null!"), clsTranslate.TranslateString("Information"), MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
             txtVendorName.Focus();
             return(false);
         }
         if (cboVendorType.SelectedIndex == -1)
         {
             MessageBox.Show(clsTranslate.TranslateString("vendor type") + clsTranslate.TranslateString(" can not be null!"), clsTranslate.TranslateString("Information"), MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
             cboVendorType.Focus();
             return(false);
         }
         if (Util.IsChina(txtNo.Text.Trim()))
         {
             MessageBox.Show(clsTranslate.TranslateString("Purchase no") + clsTranslate.TranslateString(" can not be chinese!"), clsTranslate.TranslateString("Information"), MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
             txtNo.Focus();
             return(false);
         }
         if (cboNeedInvoice.SelectedIndex == -1)
         {
             MessageBox.Show(clsTranslate.TranslateString("Need invoice") + clsTranslate.TranslateString(" can not be null!"), clsTranslate.TranslateString("Information"), MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
             cboNeedInvoice.Focus();
             return(false);
         }
         modVendorList mod = new modVendorList();
         mod.VendorName  = txtVendorName.Text.Trim();
         mod.VendorType  = cboVendorType.Text;
         mod.Status      = cboStatus.SelectedIndex;
         mod.Currency    = cboCurrency.SelectedValue.ToString();
         mod.No          = txtNo.Text.Trim().Replace("*", "");
         mod.Linkman     = txtLinkman.Text.Trim();
         mod.Tel         = txtTel.Text.Trim();
         mod.Fax         = txtFax.Text.Trim();
         mod.Addr        = txtAddr.Text.Trim();
         mod.Remark      = txtRemark.Text.Trim();
         mod.NeedInvoice = cboNeedInvoice.SelectedIndex;
         mod.UpdateUser  = Util.UserId;
         bool ret = false;
         if (_status == 1)
         {
             ret = _dal.Insert(mod, out Util.emsg);
         }
         else if (_status == 2)
         {
             ret = _dal.Update(txtVendorName.Text, mod, out Util.emsg);
         }
         if (ret)
         {
             Util.ChangeStatus(this, true);
             DBGrid.Enabled = true;
             LoadData();
             FindText = mod.VendorName;
             Find();
         }
         return(ret);
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, clsTranslate.TranslateString("Information"), MessageBoxButtons.OK, MessageBoxIcon.Information);
         return(false);
     }
     finally
     {
         this.Cursor = Cursors.Default;
     }
 }