コード例 #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");
                }
            }
        }