コード例 #1
0
        private void SaveBtn_Click(object sender, EventArgs e)
        {
            String CUST_FNAME    = firstName.Text.ToString();
            String CUST_LNAME    = lastName.Text.ToString();
            String CUST_MOB      = mobile.Text.ToString();
            String CUST_EMAIL    = email.Text.ToString();
            String CUST_STATE    = state.Text.ToString();
            String CUST_DISTRICT = district.Text.ToString();;
            String CUST_AREA     = area.Text.ToString();;
            String CUST_IMG_LOC  = custImgLoc;
            String CUST_ID       = custId.Text.ToString();

            if (string.IsNullOrEmpty(CUST_FNAME))
            {
                errorProvider1.SetError(firstName, "FirstName required!");
                firstName.Focus();
                return;
            }

            else if (!(validate.IsAlpha(CUST_FNAME)))
            {
                errorProvider1.SetError(firstName, "FirstName Should be albhabet!");
                firstName.Clear();
                firstName.Focus();
                return;
            }
            else if (!(String.IsNullOrEmpty(CUST_LNAME)) && !(validate.IsAlpha(CUST_LNAME)))
            {
                errorProvider1.SetError(lastName, "LastName Should be albhabet!");
                lastName.Clear();
                lastName.Focus();
                return;
            }
            else if (!(String.IsNullOrEmpty(CUST_MOB)) && !(validate.IsNumeric(CUST_MOB)))
            {
                errorProvider1.SetError(mobile, "Mobile No Should be Numeric");
                mobile.Clear();
                mobile.Focus();
                return;
            }
            else if (!(String.IsNullOrEmpty(CUST_MOB)) && !(CUST_MOB.Length == 10))
            {
                errorProvider1.SetError(mobile, "Mobile No Should contain 10 Digit");
                mobile.Clear();
                mobile.Focus();
                return;
            }
            else if (!(String.IsNullOrEmpty(CUST_EMAIL)) && !(validate.IsValidEmail(CUST_EMAIL)))
            {
                errorProvider1.SetError(email, "Email Is not Valid");
                email.Clear();
                email.Focus();
                return;
            }

            else if (String.IsNullOrEmpty(CUST_STATE))
            {
                errorProvider1.SetError(state, "Enter State!");
                return;
            }

            else if (String.IsNullOrEmpty(CUST_DISTRICT))
            {
                errorProvider1.SetError(district, "Enter District!");
                return;
            }
            else if (String.IsNullOrEmpty(CUST_AREA))
            {
                errorProvider1.SetError(area, "Enter Area!");
                return;
            }


            CustomerDataLoad customerDataLoad = new CustomerDataLoad();

            if (!(String.IsNullOrEmpty(custImgLoc)))
            {
                MessageBox.Show(custImgLoc);
                if (customerDataLoad.updateCustomerData(CUST_FNAME, CUST_LNAME, CUST_MOB, CUST_EMAIL, CUST_STATE, CUST_DISTRICT, CUST_AREA, CUST_IMG_LOC, CUST_ID))
                {
                    MessageBox.Show("Customer Data Updated Successfully");
                    fillData.fillDataGridView(this.customerDataGridView, this.tableName, this.columnsToPull, this.columnNameToDisplay, this.columnIndexToHide);
                    disableCustDetailsEditable();
                }
                else
                {
                    MessageBox.Show("Error!! Customer Data Not Updated");
                }
            }
            else
            {
                CUST_IMG_LOC = "";
                if (customerDataLoad.updateCustomerData(CUST_FNAME, CUST_LNAME, CUST_MOB, CUST_EMAIL, CUST_STATE, CUST_DISTRICT, CUST_AREA, CUST_IMG_LOC, CUST_ID))
                {
                    MessageBox.Show("Customer Data Updated Successfully");
                    fillData.fillDataGridView(this.customerDataGridView, this.tableName, this.columnsToPull, this.columnNameToDisplay, this.columnIndexToHide);
                    disableCustDetailsEditable();
                }
                else
                {
                    MessageBox.Show("Error!! Customer Data Not Updated");
                }
            }
        }
コード例 #2
0
        private void addCustomerSaveBtn_Click(object sender, EventArgs e)
        {
            String CUST_FNAME    = custFirstName.Text.ToString();
            String CUST_LNAME    = custLastName.Text.ToString();
            String CUST_MOB      = custMobile.Text.ToString();
            String CUST_EMAIL    = custEmail.Text.ToString();
            String CUST_STATE    = stateSelected;
            String CUST_DISTRICT = distSelected;
            String CUST_AREA     = areaSelected;
            String CUST_IMG_LOC  = custImgLoc;;

            if (string.IsNullOrEmpty(CUST_FNAME))
            {
                errorProvider1.SetError(custFirstName, "FirstName required!");
                custFirstName.Focus();
                custFirstName.Clear();
                return;
            }
            else if (Validation.IsContainSPace((CUST_FNAME)))
            {
                errorProvider1.SetError(custFirstName, "Enter First Name Without Space");
                custFirstName.Clear();
                custFirstName.Focus();
                return;
            }
            else if (!(validate.IsAlpha(CUST_FNAME)))
            {
                errorProvider1.SetError(custFirstName, "FirstName Should be albhabet!");
                custFirstName.Clear();
                custFirstName.Focus();
                return;
            }
            else if (!(String.IsNullOrEmpty(CUST_LNAME)) && !(validate.IsAlpha(CUST_LNAME)))
            {
                errorProvider1.SetError(custLastName, "LastName Should be albhabet!");
                custLastName.Clear();
                custLastName.Focus();
                return;
            }
            else if (!(String.IsNullOrEmpty(CUST_MOB)) && !(validate.IsNumeric(CUST_MOB)))
            {
                errorProvider1.SetError(custMobile, "Mobile No Should be Numeric");
                custMobile.Clear();
                custMobile.Focus();
                return;
            }
            else if (!(String.IsNullOrEmpty(CUST_MOB)) && !(CUST_MOB.Length == 10))
            {
                errorProvider1.SetError(custMobile, "Mobile No Should contain 10 Digit");
                custMobile.Clear();
                custMobile.Focus();
                return;
            }
            else if (!(String.IsNullOrEmpty(CUST_EMAIL)) && !(validate.IsValidEmail(CUST_EMAIL)))
            {
                errorProvider1.SetError(custEmail, "Email Is not Valid");
                custEmail.Clear();
                custEmail.Focus();
                return;
            }

            else if (String.IsNullOrEmpty(CUST_STATE))
            {
                errorProvider1.SetError(custStateComboBox, "Select State!");
                return;
            }

            else if (String.IsNullOrEmpty(CUST_DISTRICT))
            {
                errorProvider1.SetError(custDistrictComboBox, "Select District!");
                return;
            }
            else if (String.IsNullOrEmpty(CUST_AREA))
            {
                errorProvider1.SetError(custAreaComboBox, "Select Area!");
                return;
            }


            CustomerDataLoad customerDataLoad = new CustomerDataLoad();

            if (customerDataLoad.saveCustomerData(CUST_FNAME, CUST_LNAME, CUST_MOB, CUST_EMAIL, CUST_STATE, CUST_DISTRICT, CUST_AREA, CUST_IMG_LOC))
            {
                MessageBox.Show("Customer Data Saved Successfully");
            }
            else
            {
                MessageBox.Show("Customer Data Not Saved");
            }
        }