Пример #1
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                ToolBAL         objBAL             = new ToolBAL();
                SupplierDetails objSupplierDetails = new SupplierDetails();
                objSupplierDetails.SupplierName = txtFirstName.Text;
                //objSupplierDetails.MiddleName = txtMiddleName.Text;
                //objSupplierDetails.LastName = txtLastName.Text;

                if (txtCompany.Text.ToString() == string.Empty)
                {
                    MessageBox.Show("Please enter company name.");
                    txtCompany.Focus();
                    return;
                }
                objSupplierDetails.Company           = txtCompany.Text;
                objSupplierDetails.Displayname       = txtDisplayName.Text;
                objSupplierDetails.Mobile            = txtMobile.Text;
                objSupplierDetails.Email             = txtEmail.Text;
                objSupplierDetails.Fax               = txtFax.Text;
                objSupplierDetails.AccountNo         = txtAccountNo.Text;
                objSupplierDetails.PanNumber         = txtPanNo.Text;
                objSupplierDetails.TaxRegistrationNo = txtRegisterNo.Text;
                if (txtSupplierCode.Text.ToString() == string.Empty)
                {
                    MessageBox.Show("Please enter Supplier Code.");
                    txtSupplierCode.Focus();
                    return;
                }
                objSupplierDetails.SupplierCode = txtSupplierCode.Text;

                //objSupplierDetails.Address = txtAddress.Text;
                //objSupplierDetails.Phone = txtPhone.Text;
                //objSupplierDetails.City = txtCity.Text;
                //objSupplierDetails.State = txtState.Text;
                //objSupplierDetails.Country = txtCountry.Text;
                //objSupplierDetails.PostalCode = txtPostalCode.Text;

                if (txtPhone.Text == "Phone")
                {
                    objSupplierDetails.Phone = string.Empty;
                }
                else
                {
                    objSupplierDetails.Phone = txtPhone.Text;
                }
                if (txtAddress.Text == "Street")
                {
                    objSupplierDetails.Address = string.Empty;
                }
                else
                {
                    objSupplierDetails.Address = txtAddress.Text;
                }
                if (txtState.Text == "State")
                {
                    objSupplierDetails.State = string.Empty;
                }
                else
                {
                    objSupplierDetails.State = txtState.Text;
                }

                if (txtCity.Text == "City/Town")
                {
                    objSupplierDetails.City = string.Empty;
                }
                else
                {
                    objSupplierDetails.City = txtCity.Text;
                }
                if (txtCountry.Text == "Country")
                {
                    objSupplierDetails.Country = string.Empty;
                }
                else
                {
                    objSupplierDetails.Country = txtCountry.Text;
                }
                if (txtPostalCode.Text == "Postal Code")
                {
                    objSupplierDetails.PostalCode = string.Empty;
                }
                else
                {
                    objSupplierDetails.PostalCode = txtPostalCode.Text;
                }

                objSupplierDetails.Notes  = txtNote.Text;
                objSupplierDetails.UserId = Login.UserId;

                int i = objBAL.AddSupplierDetails(objSupplierDetails);

                if (i != 0)
                {
                    MessageBox.Show("Data Saved Successfully.");
                    Clear();
                }
                else
                {
                    MessageBox.Show("Data Insertion Failed.");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, this.Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
        }