示例#1
0
    public static ClientHair CreateCustomerObjectAndAssignData(ProjectStructs.Client customer)
    {
        var Client = new ClientHair();

        Client.IdCustomer          = customer.id; //arbitrary as i do not need the id for inserting new customers
        Client.FirstNameCustomer   = UppercaseFirstLetter(customer.firstName);
        Client.LastNameCustomer    = UppercaseFirstLetter(customer.lastName);
        Client.PhoneNumberCustomer = customer.phoneCell;
        Client.EmailCustomer       = customer.email;
        return(Client);
    }
示例#2
0
 protected void BtnNewCustomer_Click(object sender, EventArgs e)
 {
     Page.Validate("RegistrationInfoGroup");
     if (Page.IsValid == true)
     {
         ProjectStructs.Client customer = CreateAHashOfNewCustomerDataEntered();
         var Client = ClientHair.CreateCustomerObjectAndAssignData(customer);
         RegisterCustomer(Client);
         PopulateCustomerNamesComboBox(LoadCustomerNamesIntoDataTable());
         UpdtPanelMessageCenter.Update();
         ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "VanishMessageCenterNewCust", "vanishMessageCenter();", true);
     }
 }
示例#3
0
    public static SqlCommand InsertNewCustomerDataIntoDB(ClientHair clientToRegister, SqlConnection connection)
    {
        var command = new SqlCommand("StoredPro_InsertCustomerData", connection);

        command.CommandType = CommandType.StoredProcedure;
        command.Parameters.Add("@FirstName", SqlDbType.NVarChar, 20).Value = clientToRegister.FirstNameCustomer;
        command.Parameters.Add("@LastName", SqlDbType.NVarChar, 20).Value  = clientToRegister.LastNameCustomer;
        command.Parameters.Add("@Phone", SqlDbType.NVarChar, 15).Value     = clientToRegister.PhoneNumberCustomer;
        command.Parameters.Add("@Email", SqlDbType.NVarChar, 240).Value    = clientToRegister.EmailCustomer;

        command.Parameters.Add("@OperationStatus", SqlDbType.NVarChar, 23).Direction = ParameterDirection.Output;
        command.Parameters.Add("@CustomerAlreadyExist", SqlDbType.TinyInt).Direction = ParameterDirection.Output;

        connection.Open();
        command.ExecuteNonQuery();
        return(command);
    }
示例#4
0
 //Save customer data into DB
 public void RegisterCustomer(ClientHair clientToRegister)
 {
     using (SqlConnection connection = HairStylistConnectionString.Connection())
     {
         try
         {
             var    command      = ClientHair.InsertNewCustomerDataIntoDB(clientToRegister, connection);
             int    insertResult = ClientHair.DetermineWhetherCustomerAlreadyExistInDB(command);
             string message      = ClientHair.GetMessageResultFromInsertingCustomer(command);
             DisplayInsertResultToUser(message, insertResult);
             LblMessageToUser.Visible = true;
             command.Dispose();
         }
         catch (System.Data.SqlClient.SqlException ex)
         {
             string str;
             str  = "Source:" + ex.Source;
             str += "\n" + "Message:" + ex.Message;
             AssignMessageToLabelWithResultFromOperation(AppConstants.LblMessage.ErrorForecolor, AppConstants.LblMessage.ErrorBackgroundColor, str);
         }
     }
 }