示例#1
0
        private void Add_Click(object sender, EventArgs e)
        {
            try
            {
                ent = new Cfirst();
                //change quantities between tables
                store sof = (from em in ent.stores where em.name == fromStore.Text select em).First();
                store sot = (from em in ent.stores where em.name == toStore.Text select em).First();

                Variety vf = (from em in ent.Varieties where em.storeID == sof.storeId select em).First();
                Variety vt = (from em in ent.Varieties where em.storeID == sot.storeId select em).First();
                vf.quantity = vf.quantity - int.Parse(quantity.Text);
                vt.quantity = vf.quantity - int.Parse(quantity.Text);
                transform tr = new transform();
                tr.transformid        = int.Parse(transformId.Text);
                tr.sfrom              = fromStore.Text;
                tr.sto                = toStore.Text;
                tr.varieties          = varieties.Text;
                tr.supplier           = supplier.Text;
                tr.production_history = DateTime.Parse(pHistory.Text);
                tr.quantity           = int.Parse(quantity.Text);
                tr.Expiry             = expiry.Text;
                ent.transforms.Add(tr);
                ent.SaveChanges();
                gridupdate();
            }
            catch (Exception)
            {
                MessageBox.Show("Something wrong in Data entry");
            }
        }
示例#2
0
        private void btnedit_Click(object sender, EventArgs e)
        {
            try
            {
                ent = new Cfirst();
                int     code = int.Parse(varietiesCode.Text);
                Variety vi   = (from em in ent.Varieties where em.code == code select em).FirstOrDefault();
                vi.code          = varietiesCode.Text == string.Empty ? vi.code : int.Parse(varietiesCode.Text);
                vi.vName         = variatiesName.Text == string.Empty ? vi.vName : variatiesName.Text;
                vi.measruingUnit = messurementUnit.Text == string.Empty ? vi.measruingUnit :
                                   messurementUnit.Text;
                vi.supplier       = supplierName.Text == string.Empty ? vi.supplier : supplierName.Text;
                vi.productionDate = productionDate.Text == string.Empty ? vi.productionDate :
                                    DateTime.Parse(productionDate.Text);
                vi.quantity = qantity.Text == string.Empty ? vi.quantity : int.Parse(qantity.Text);
                vi.expire   = expire.Text == string.Empty ? vi.expire : int.Parse(expire.Text);

                vi.storeID = storedId.Text == string.Empty ? vi.storeID : int.Parse(storedId.Text);
                ent.SaveChanges();
                gridupdate();
            }
            catch (Exception)
            {
                MessageBox.Show("problem with the data");
            }
        }
示例#3
0
 private void btnadd_Click(object sender, EventArgs e)
 {
     try
     {
         Variety vi = new Variety();
         ent               = new Cfirst();
         vi.code           = int.Parse(varietiesCode.Text);
         vi.vName          = variatiesName.Text;
         vi.measruingUnit  = messurementUnit.Text;
         vi.storeID        = int.Parse(storedId.Text);
         vi.quantity       = int.Parse(qantity.Text);
         vi.productionDate = DateTime.Parse(productionDate.Text);
         vi.supplier       = supplierName.Text;
         vi.expire         = int.Parse(expire.Text);
         ent.Varieties.Add(vi);
         varietiesCode.Text = variatiesName.Text = messurementUnit.Text = storedId.Text
                                                                              = string.Empty;
         ent.SaveChanges();
         gridupdate();
     }
     catch (Exception)
     {
         MessageBox.Show("fault in data entering");
     }
 }
示例#4
0
 private void btndelete_Click(object sender, EventArgs e)
 {
     try
     {
         ent = new Cfirst();
         int     id = int.Parse(varietiesCode.Text);
         Variety vi = (from em in ent.Varieties where em.code == id select em).FirstOrDefault();
         ent.Varieties.Remove(vi);
         ent.SaveChanges();
         gridupdate();
     }
     catch (Exception)
     {
         MessageBox.Show("problem in Data entry");
     }
 }