Exemplo n.º 1
0
        private async void processData(bool isEdit)
        {
            errorProvider1.Clear();
            string name     = nametextBox.Text;
            string phone    = phoneMaskedTextBox.Text;
            string repId    = repIdTextBox.Text;
            string address  = addresstextBox.Text;
            string other    = othertextBox.Text;
            string username = usernameTextBox.Text;
            string password = passwordTextBox.Text;

            if (isEdit)
            {
                salesRepModel.name     = name;
                salesRepModel.phone    = phone;
                salesRepModel.address  = address;
                salesRepModel.other    = other;
                salesRepModel.username = username;
                salesRepModel.password = password;
                salesRepModel.repId    = repId;

                if (!MessagePrompt.displayPrompt("Edit", "edit this salesRep"))
                {
                    return;
                }

                MessageBox.Show(await DatabaseOperations.editSalesRep(salesRepModel) ? "Data updated successfully" : "Data updating failed");
            }
            else
            {
                SalesRepDataModel salesRep = new SalesRepDataModel
                {
                    name     = name,
                    phone    = phone,
                    repId    = repId,
                    address  = address,
                    other    = other,
                    username = username,
                    password = password
                };

                if (!MessagePrompt.displayPrompt("Create New", "create new salesRep"))
                {
                    return;
                }

                DatabaseOperations.addSalesRep(salesRep);

                MessageBox.Show("Sales Rep created successfully");

                nametextBox.Clear();
                phoneMaskedTextBox.Clear();
                addresstextBox.Clear();
                othertextBox.Clear();
                usernameTextBox.Clear();

                repIdTextBox.Text    = GenerateIDs.salesRepId();
                passwordTextBox.Text = GenerateIDs.password();
            }
        }
Exemplo n.º 2
0
        public AddSalesRepForm()
        {
            InitializeComponent();

            repIdTextBox.Text    = GenerateIDs.salesRepId();
            passwordTextBox.Text = GenerateIDs.password();
        }
Exemplo n.º 3
0
 public AddClient()
 {
     InitializeComponent();
     passwordTextBox.Text = GenerateIDs.password();
     loadCombos();
 }
Exemplo n.º 4
0
        private async void processData(bool isEdit)
        {
            errorProvider1.Clear();
            string name          = nametextBox.Text;
            string phone         = phoneMaskedTextBox.Text;
            string address       = addresstextBox.Text;
            string other         = othertextBox.Text;
            string username      = usernameTextBox.Text;
            string password      = passwordTextBox.Text;
            string role          = rolesComboBox.Text;
            string storelocation = storeLocationComboBox.Text;

            if (isEdit)
            {
                clientModel.name          = name;
                clientModel.phone         = phone;
                clientModel.address       = address;
                clientModel.other         = other;
                clientModel.username      = username;
                clientModel.password      = password;
                clientModel.role          = role;
                clientModel.storeLocation = storelocation;

                if (!MessagePrompt.displayPrompt("Edit", "edit this client"))
                {
                    return;
                }

                MessageBox.Show(await DatabaseOperations.editClient(clientModel) ? "Client edited successfully" : "client editing failed");
            }
            else
            {
                if (!MessagePrompt.displayPrompt("Create New", "create new client"))
                {
                    return;
                }

                ClientDataModel clientModel = new ClientDataModel();
                clientModel.name          = name;
                clientModel.phone         = phone;
                clientModel.address       = address;
                clientModel.other         = other;
                clientModel.username      = username;
                clientModel.password      = password;
                clientModel.role          = role;
                clientModel.storeLocation = storelocation;

                bool success = await DatabaseOperations.addClient(clientModel);

                if (success)
                {
                    MessageBox.Show("Client created successfully");
                    nametextBox.Clear();
                    phoneMaskedTextBox.Clear();
                    addresstextBox.Clear();
                    othertextBox.Clear();
                    usernameTextBox.Clear();


                    passwordTextBox.Text = GenerateIDs.password();
                }
                else
                {
                    MessageBox.Show("Client creation failed.");
                }
            }
        }