Exemple #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");
            }
        }
Exemple #2
0
        private void storeName_SelectedIndexChanged(object sender, EventArgs e)
        {
            ent = new Cfirst();
            store so = (from em in ent.stores where em.name == storeName.Text select em).First();

            address.Text      = so.address;
            adminstrator.Text = so.admnistrator;
            int id = so.storeId;
            var vr = (from en in ent.Varieties where en.storeID == id select en).ToList();

            dataGridView1.DataSource = vr;
            dataGridView1.Columns["store"].Visible = false;
        }
Exemple #3
0
 private void btndelete_Click(object sender, EventArgs e)
 {
     try
     {
         ent = new Cfirst();
         int   id = int.Parse(storedId.Text);
         store so = (from en in ent.stores where en.storeId == id select en).FirstOrDefault();
         ent.stores.Remove(so);
         ent.SaveChanges();
         gridupdate();
     }
     catch (Exception)
     {
         MessageBox.Show("Fault in data entry");
     }
 }
Exemple #4
0
 private void storeName_SelectedIndexChanged(object sender, EventArgs e)
 {
     try
     {
         ent = new Cfirst();
         store so = (from em in ent.stores where em.name == storeName.Text select em).FirstOrDefault();
         var   va = from em in ent.Varieties where em.storeID == so.storeId select em;
         variatiesName.Items.Clear();
         foreach (var i in va)
         {
             variatiesName.Items.Add(i.vName);
         }
     }
     catch (Exception)
     {
         MessageBox.Show("something went wrong in dataEntry");
     }
 }
Exemple #5
0
 private void btnedit_Click(object sender, EventArgs e)
 {
     try
     {
         ent = new Cfirst();
         int   id = int.Parse(storedId.Text);
         store so = (from en in ent.stores where en.storeId == id select en).FirstOrDefault();
         so.name         = storedName.Text == string.Empty ? so.name : storedName.Text;
         so.address      = storedAddress.Text == string.Empty ? so.address : storedAddress.Text;
         so.admnistrator = storedAdminstrator.Text == string.Empty ? so.admnistrator : storedAdminstrator.Text;
         ent.SaveChanges();
         gridupdate();
     }
     catch (Exception)
     {
         MessageBox.Show("Fault in data entry");
     }
 }
Exemple #6
0
        private void btnadd_Click(object sender, EventArgs e)
        {
            try
            {
                store so = new store();
                ent             = new Cfirst();
                so.storeId      = int.Parse(storedId.Text);
                so.name         = storedName.Text;
                so.address      = storedAddress.Text;
                so.admnistrator = storedAdminstrator.Text;

                ent.stores.Add(so);
                ent.SaveChanges();
                storedId.Text = storedName.Text = storedAddress.Text = storedAdminstrator.Text
                                                                           = string.Empty;
                gridupdate();
            }
            catch (Exception)
            {
                MessageBox.Show("can't add 2 stores witn the same id");
            }
        }