Exemple #1
0
 public static void EditClick(object sender, EventArgs e)
 {
     var type = sender.GetType();
     Form form = null;
     if(type == typeof(ToolStripMenuItem))
     {
         var i = (sender as ToolStripMenuItem).Tag as Item;
         form = new EditWindow(new ProductEdit(i));
     }
     else if(type == typeof(Button))
     {
         var tag = (sender as Button).Tag;
         type = tag.GetType();
         if(type == typeof(Customer))
         {
             form = new EditWindow(new CustomerEdit(tag as Customer));
         }
     }
     if (form != null) form.ShowDialog();
 }
Exemple #2
0
        private void dgData_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            if (((EditType)Tag == EditType.OrderEdit) && e.RowIndex > -1 && e.RowIndex < dgData.Rows.Count - 1)
            {
                DialogResult dr = DialogResult.None;
                var row = ((DataRowView)(dgData.Rows[e.RowIndex].DataBoundItem)).Row;
                if (e.ColumnIndex == 1)
                {
                    if ((dr = MessageBox.Show("Are you SURE to DELETE this record?", "Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Warning)) == DialogResult.Yes)
                    {
                        try
                        {
                            DB.Instance.Delete("delete from order where inventory_id=" + row["id"] + " and order_id=" + id);
                            MessageBox.Show("Order Deleted!");
                        }
                        catch (Exception ex) { MessageBox.Show(ex.Message); }
                    }
                }
                else if (e.ColumnIndex == 0)
                {

                            dr = new EditWindow(
                                new OrderDetailEdit((uint)row["id"])).ShowDialog();
                }
                if (dr == DialogResult.OK || dr == DialogResult.Yes)
                {
                    refresh();
            #if DEBUG
                    Console.WriteLine("refresh");
            #endif
                }
            }
        }
Exemple #3
0
 private void dgData_CellClick(object sender, DataGridViewCellEventArgs e)
 {
     if (e.RowIndex > -1 && e.RowIndex < dgData.Rows.Count - 1)
     {
         DialogResult dr = DialogResult.None;
         var row = ((DataRowView)(dgData.Rows[e.RowIndex].DataBoundItem)).Row;
         if (e.ColumnIndex == dgData.Columns.Count - 1)
         {
             if((dr = MessageBox.Show("Are you SURE to DELETE this record?", "Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Warning)) == DialogResult.Yes)
             {
                 try
                 {
                     switch (type)
                     {
                         case EditType.InventoryEdit:
                             break;
                         case EditType.CustomerEdit:
                             DB.Instance.Delete("delete from customer where id=" + row[0]);
                             break;
                         case EditType.EmployeeEdit:
                             DB.Instance.Delete("delete from employee where id=" + row[0]);
                             break;
                         case EditType.OrderEdit:
                             DB.Instance.Delete("delete from order_inventory where order_id=" + row[0]);
                             DB.Instance.Delete("delete from order where id=" + row[0]);
                             break;
                     }
                     MessageBox.Show("Record Deleted!");
                 }
                 catch (Exception ex) { MessageBox.Show(ex.Message); }
             }
         }
         else if (e.ColumnIndex == dgData.Columns.Count - 2)
         {
             switch (type) {
                 case EditType.InventoryEdit:
                     break;
                 case EditType.CustomerEdit:
                     dr = new EditWindow(
                         new CustomerEdit(
                             new Customer(
                                 (uint)row[0],
                                 row[1] as string,
                                 row[2] as string,
                                 DateTime.Parse(row[3].ToString()),
                                 row[4] as string,
                                 row[5] as string,
                                 row[6] as string,
                                 row[7] as string,
                                 row[8] as string,
                                 row[9] as string,
                                 row[10] as string
                                 ))).ShowDialog();
                     break;
                 case EditType.EmployeeEdit:
                     dr = new EditWindow(
                         new EmployeeEdit(
                             new Employee(
                                 (uint)row[0],
                                 row[1] as string,
                                 row[2] as string,
                                 DateTime.Parse(row[3].ToString()),
                                 row[4] as string,
                                 row[5] as string,
                                 row[6] as string,
                                 row[7] as string,
                                 row[8] as string,
                                 row[9] as string
                                 ))).ShowDialog();
                     break;
                 case EditType.OrderEdit:
                     dr = new EditWindow(
                         new OrderEdit((uint)row[0])).ShowDialog();
                     break;
             }
         }
         if (dr == DialogResult.OK || dr == DialogResult.Yes)
         {
             fetch(currentQuery);
     #if DEBUG
             Console.WriteLine("refresh");
     #endif
         }
     }
 }