コード例 #1
0
ファイル: Update.aspx.cs プロジェクト: atiburrahman09/Signbd
        protected void updateButton_Click(object sender, EventArgs e)
        {
            CustomerBLL customer = new CustomerBLL();

            try
            {
                if (customerIdForUpdateHiddenField.Value.Trim() == "")
                {
                    msgbox.Visible = true; msgTitleLabel.Text = "Exception!!!"; msgDetailLabel.Text = "Customer not found to update.";
                }
                else if (customerNameTextBox.Text == "")
                {
                    msgbox.Visible = true; msgTitleLabel.Text = "Validation!!!"; msgDetailLabel.Text = "Customer Name field is required.";
                }
                else if (addressTextBox.Text == "")
                {
                    msgbox.Visible = true; msgTitleLabel.Text = "Validation!!!"; msgDetailLabel.Text = "Address field is required.";
                }
                //else if (joiningSalesCenterDropDownList.Text == "")
                //{
                //    msgbox.Visible = true; msgTitleLabel.Text = "Validation!!!"; msgDetailLabel.Text = "Joining Sales Center field is required.";
                //}
                else
                {
                    customer.CustomerId = customerIdForUpdateHiddenField.Value.Trim();
                    customer.CustomerName = customerNameTextBox.Text.Trim();
                    customer.ContactNumber = contactNumberTextBox.Text.Trim();
                    customer.Email = emailTextBox.Text.Trim();
                    customer.Country = ""; //countryTextBox.Text.Trim();
                    customer.City = cityTextBox.Text.Trim();
                    customer.District = ""; // districtTextBox.Text.Trim();
                    customer.PostalCode = ""; //postalCodeTextBox.Text.Trim();
                    customer.Address = addressTextBox.Text.Trim();
                    customer.NationalId = "";//nationalIdTextBox.Text.Trim();
                    customer.PassportNumber = "";//passportNumberTextBox.Text.Trim();
                    customer.JoiningSalesCenterId = joiningSalesCenterDropDownList.SelectedValue.Trim();
                    customer.Description = txtbxDescription.Text.Trim();

                    customer.UpdateCustomer();

                    customerIdForUpdateHiddenField.Value = "";

                    string message = "Customer <span class='actionTopic'>Updated</span> Successfully.";
                    MyAlertBox("var callbackOk = function () { MyOverlayStart(); window.location = \"/UI/Customer/List.aspx\"; }; SuccessAlert(\"" + "Process Succeed" + "\", \"" + message + "\", callbackOk);");
                }
            }
            catch (Exception ex)
            {
                string message = ex.Message;
                if (ex.InnerException != null) { message += " --> " + ex.InnerException.Message; }
                MyAlertBox("ErrorAlert(\"" + ex.GetType() + "\", \"" + message + "\", \"\");");
            }
            finally
            {
                customer = null;
            }
        }