Exemplo n.º 1
0
        private void updateBtn_Click(object sender, EventArgs e)
        {
            int selectedRowIndex = 0;

            if (table.SelectedCells.Count > 0)
            {
                Software.Model.Customer_Type type = new Software.Model.Customer_Type();

                selectedRowIndex = table.SelectedCells[0].RowIndex;
                DataGridViewRow selectedRow = table.Rows[selectedRowIndex];

                type.Id            = Convert.ToInt32(Convert.ToString(selectedRow.Cells["Id"].Value));
                type.Type_Title    = typeTitleBox.Text;
                type.Discount_Rate = Convert.ToInt32(discountBox.Text);
                Software.Database.SQL.Customer_TypeDB.UpdateCustomer_Type(type);
            }
            else
            {
                MetroFramework.MetroMessageBox.Show(this, "You must select a row to update its value!", "Invalid Selection", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }

            DoRefresh();
            table.CurrentCell = table.Rows[selectedRowIndex].Cells[0];
            table.Rows[selectedRowIndex].Selected = true;
        }
Exemplo n.º 2
0
 private void createBtn_Click(object sender, EventArgs e)
 {
     Software.Model.Customer_Type type = new Software.Model.Customer_Type
     {
         Type_Title    = typeTitileBox.Text,
         Order_Count   = Int32.Parse(orderCountBox.Text),
         Total_Bill    = Int32.Parse(totalBillBox.Text),
         Discount_Rate = Int32.Parse(discountBox.Text)
     };
     Software.Database.SQL.Customer_TypeDB.InsertCustomer_Type(type);
     MetroFramework.MetroMessageBox.Show(this, "Sucess", "Data Inserted Successfully", MessageBoxButtons.OK, MessageBoxIcon.Information);
     Close();
 }
        private void table_SelectionChanged(object sender, System.EventArgs e)
        {
            if (table.SelectedCells.Count > 0)
            {
                int             selectedRowIndex = table.SelectedCells[0].RowIndex;
                DataGridViewRow selectedRow      = table.Rows[selectedRowIndex];
                pictureBox.ImageLocation = Convert.ToString(selectedRow.Cells["Picture"].Value);
                nameBox.Text             = Convert.ToString(selectedRow.Cells["Name"].Value);
                contactBox.Text          = Convert.ToString(selectedRow.Cells["Contact_No"].Value);
                emailBox.Text            = Convert.ToString(selectedRow.Cells["Email"].Value);
                addressBox.Text          = Convert.ToString(selectedRow.Cells["Address"].Value);

                Software.Model.Customer_Type type = types.Single(t => t.Id == Convert.ToInt32(Convert.ToString(selectedRow.Cells["Type_Id"].Value)));
                typeComboBox.SelectedIndex = typeComboBox.FindStringExact(type.Type_Title);
            }
        }