Exemplo n.º 1
0
        // main 3 buttons of supply permission


        private void btn_EditSP_Click(object sender, EventArgs e)
        {
            try
            {
                groupBox2.Enabled = true;
                if (txt_SPid.Text != string.Empty)
                {
                    var id = int.Parse(txt_SPid.Text);
                    Supply_Permission sp = db.Supply_Permission.FirstOrDefault(a => a.Per_Id == id);
                    txt_SPdate.Text            = sp.Per_Date.ToString();
                    cb_Warehouses.SelectedItem = sp.War_Name;
                    cb_Suppliers.SelectedItem  = sp.Sup_Name;
                    var query = db.Supply_Permission_Product.Where(a => a.Per_Id == sp.Per_Id);
                    dgv_Products.DataSource = query.ToList();
                }
                btn_SubmitSP.Enabled = false;
                btn_DeleteSP.Enabled = false;
                btn_ModifySP.Enabled = true;
                btn_EditSP.Enabled   = false;
                txt_SPid.ReadOnly    = true;
            }
            catch
            {
                MessageBox.Show("Can't find permission with giving information");
            }
        }
Exemplo n.º 2
0
 // create permission button handle
 private void btn_Create_Click(object sender, EventArgs e)
 {
     if (txt_SPid.Text != string.Empty && txt_SPdate.Text != string.Empty)
     {
         Supply_Permission sp = new Supply_Permission()
         {
             Per_Id   = int.Parse(txt_SPid.Text),
             Per_Date = DateTime.Parse(txt_SPdate.Text),
             War_Name = cb_Warehouses.SelectedItem.ToString(),
             Sup_Name = cb_Suppliers.SelectedItem.ToString()
         };
         db.Supply_Permission.Add(sp);
         db.SaveChanges();
         MessageBox.Show("Permission created successfully you can now add products");
         dgv_Products.DataSource = db.Supply_Permission_Product.Where(a => a.Per_Id == sp.Per_Id).ToList();
         groupBox1.Enabled       = true;
         groupBox2.Enabled       = false;
         if (txt_Quantity.Text != string.Empty || txt_PD.Text != string.Empty || txt_ED.Text != string.Empty)
         {
             txt_Quantity.Text = string.Empty;
             txt_PD.Text       = string.Empty;
             txt_ED.Text       = string.Empty;
         }
     }
     else
     {
         MessageBox.Show("please complete missing fields Permission No. or Permission Date");
     }
 }
Exemplo n.º 3
0
 private void btn_DeleteSP_Click(object sender, EventArgs e)
 {
     try
     {
         if (txt_Cname.Text != string.Empty)
         {
             int id = int.Parse(txt_SPid.Text);
             Supply_Permission sp = db.Supply_Permission.FirstOrDefault(a => a.Per_Id == id);
             db.Supply_Permission.Remove(sp);
             db.SaveChanges();
             MessageBox.Show("permission deleted sucessfuly");
             txt_SPid.Text   = string.Empty;
             txt_SPdate.Text = string.Empty;
         }
     }
     catch
     {
         MessageBox.Show("Can't find permission with giving information");
     }
 }
Exemplo n.º 4
0
        private void btn_ModifySP_Click(object sender, EventArgs e)
        {
            int id = int.Parse(txt_SPid.Text);
            Supply_Permission sp = db.Supply_Permission.FirstOrDefault(a => a.Per_Id == id);

            if (txt_SPdate.Text != string.Empty)
            {
                sp.Per_Date = DateTime.Parse(txt_SPdate.Text);
                sp.War_Name = cb_Warehouses.SelectedItem.ToString();
                sp.Sup_Name = cb_Suppliers.SelectedItem.ToString();
                MessageBox.Show("Product is updated");
                txt_Pid.Text   = string.Empty;
                txt_Pname.Text = string.Empty;
            }
            btn_SubmitSP.Enabled   = true;
            btn_DeleteProd.Enabled = true;
            btn_ModifyProd.Enabled = false;
            btn_EditProd.Enabled   = true;
            txt_Pid.ReadOnly       = false;
            groupBox2.Enabled      = false;
        }