Пример #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 varatiesExpiry_Load(object sender, EventArgs e)
        {
            ent = new Cfirst();
            DateTime dateTime = DateTime.Today;
            var      vi       = from em in ent.Varieties select em;

            foreach (var item in vi)
            {
                System.TimeSpan diff   = dateTime.Subtract((DateTime)item.productionDate);
                int             s      = (int)diff.Days;
                int             result = (int)(s - item.expire);
                if (result <= 60)
                {
                    if (result <= 0)
                    {
                        varietyName.Items.Add(item.vName + " Expiry End");
                    }
                    else
                    {
                        varietyName.Items.Add(item.vName + " " + result);
                    }
                }
            }
            dataGridView1.DataSource = vi.ToList();
            dataGridView1.Columns["store"].Visible = false;
        }
Пример #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 btAddP_Click(object sender, EventArgs e)
        {
            try
            {
                ent = new Cfirst();
                DismissalPermission            dp  = new DismissalPermission();
                Varieties_Dismissalpermessions vdp = new Varieties_Dismissalpermessions();

                int id = int.Parse(dissmalId.Text);
                Varieties_supplypermessions vsp = (from en in ent.Varieties_supplypermessions
                                                   where en.SupplyId == id
                                                   select en).FirstOrDefault();
                vsp.quantities       = vsp.quantities - int.Parse(varietiesQuantity.Text);
                vdp.dismissalId      = int.Parse(dissmalId.Text);
                vdp.Varieties        = variatiesName.Text;
                vdp.quantities       = int.Parse(varietiesQuantity.Text);
                dp.supplieName       = customerName.Text;
                dp.dismissalId       = int.Parse(dissmalId.Text);
                dp.history           = DateTime.Parse(permissionDate.Text);
                dp.Storename         = storeName.Text;
                dp.ptoductionHistory = DateTime.Parse(productionHistory.Text);
                dp.expiry            = expiry.Text;
                ent.Varieties_Dismissalpermessions.Add(vdp);
                ent.DismissalPermissions.Add(dp);
                ent.SaveChanges();
                gridupdate();
            }
            catch (Exception)
            {
                MessageBox.Show("something wrong in data entry");
            }
        }
Пример #5
0
 private void btAddP_Click(object sender, EventArgs e)
 {
     try
     {
         ent = new Cfirst();
         supplyPermession            sp  = new supplyPermession();
         Varieties_supplypermessions vsp = new Varieties_supplypermessions();
         vsp.SupplyId         = int.Parse(supplyId.Text);
         vsp.Varieties        = variatiesName.Text;
         vsp.quantities       = int.Parse(varietiesQuantity.Text);
         sp.SuplyId           = int.Parse(supplyId.Text);
         sp.supplieName       = supplierName.Text;
         sp.history           = DateTime.Parse(permissionDate.Text);
         sp.Storename         = storeName.Text;
         sp.supplieName       = supplierName.Text;
         sp.ptoductionHistory = DateTime.Parse(productionHistory.Text);
         sp.expiry            = expiry.Text;
         ent.Varieties_supplypermessions.Add(vsp);
         ent.supplyPermessions.Add(sp);
         ent.SaveChanges();
         gridupdate();
     }
     catch (Exception)
     {
         MessageBox.Show("Problem in Data Entry");
     }
 }
Пример #6
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");
            }
        }
Пример #7
0
        private void update_Click(object sender, EventArgs e)
        {
            try
            {
                ent = new Cfirst();
                int id = int.Parse(dissmalId.Text);
                DismissalPermission sp = (from em in ent.DismissalPermissions
                                          where em.dismissalId == id
                                          select em).FirstOrDefault();

                var vsp = (from en in ent.Varieties_Dismissalpermessions
                           where en.dismissalId == id
                           select en).FirstOrDefault();


                sp.supplieName = customerName.Text == String.Empty ? sp.supplieName : customerName.Text;
                vsp.Varieties  = variatiesName.Text == string.Empty ? vsp.Varieties : variatiesName.Text;
                vsp.quantities = varietiesQuantity.Text == string.Empty ? vsp.quantities :
                                 int.Parse(varietiesQuantity.Text);
                sp.expiry  = expiry.Text == string.Empty ? sp.expiry : expiry.Text;
                sp.history = permissionDate.Text == string.Empty ? sp.history :
                             DateTime.Parse(permissionDate.Text);
                sp.ptoductionHistory = productionHistory.Text == string.Empty ? sp.ptoductionHistory :
                                       DateTime.Parse(productionHistory.Text);
                sp.Storename = storeName.Text == string.Empty ? sp.supplieName : storeName.Text;
                ent.SaveChanges();
                gridupdate();
            }
            catch (Exception)
            {
                MessageBox.Show("somethin is wrong");
            }
        }
Пример #8
0
        private void storeName_SelectedIndexChanged(object sender, EventArgs e)
        {
            ent = new Cfirst();
            var v = (from em in ent.Varieties where em.vName == vName.Text select em).ToList();

            dataGridView1.DataSource = v;
            dataGridView1.Columns["store"].Visible = false;
        }
Пример #9
0
        private void storeName_SelectedIndexChanged(object sender, EventArgs e)
        {
            ent = new Cfirst();
            var sp = (from em in ent.supplyPermessions where em.Storename == storeName.Text select em).ToList();

            dataGridView1.DataSource = sp;
            dataGridView1.Columns["Varieties_supplypermessions"].Visible = false;
        }
Пример #10
0
        private void VarietyReport_Load(object sender, EventArgs e)
        {
            ent = new Cfirst();
            var va = from em in ent.Varieties select em;

            foreach (var item in va)
            {
                vName.Items.Add(item.vName);
            }
        }
Пример #11
0
        private void VarietiesDurationReport_Load(object sender, EventArgs e)
        {
            ent = new Cfirst();
            var va = (from em in ent.Varieties_supplypermessions select em);

            foreach (var item in va)
            {
                vName.Items.Add(item.Varieties);
            }
        }
Пример #12
0
        private void varitiesSituation_Load(object sender, EventArgs e)
        {
            ent = new Cfirst();
            var sp = from em in ent.Varieties_supplypermessions select em;

            foreach (var item in sp)
            {
                varietyName.Items.Add(item.Varieties);
            }
        }
Пример #13
0
        private void storesReport_Load(object sender, EventArgs e)
        {
            ent = new Cfirst();
            var so = from em in ent.stores select em;

            foreach (var item in so)
            {
                storeName.Items.Add(item.name);
            }
        }
Пример #14
0
        private void Form5_Load(object sender, EventArgs e)
        {
            gridupdate();
            ent = new Cfirst();
            var so = from em in ent.stores select em;

            foreach (var s in so)
            {
                storeName.Items.Add(s.name);
            }
        }
Пример #15
0
        private void vName_SelectedIndexChanged(object sender, EventArgs e)
        {
            ent = new Cfirst();
            DateTime dateTime = DateTime.Today;
            Varieties_supplypermessions vsp = (from em in ent.Varieties_supplypermessions where
                                               em.Varieties == vName.Text select em).First();
            supplyPermession sp = (from en in ent.supplyPermessions where en.SuplyId == vsp.SupplyId select en).First();

            System.TimeSpan diff = dateTime.Subtract((DateTime)sp.history);
            Duration.Text = diff.ToString();
        }
Пример #16
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;
        }
Пример #17
0
 private void gridupdate()
 {
     try
     {
         ent = new Cfirst();
         dataGridView1.DataSource = ent.DismissalPermissions.ToList();
         dataGridView2.DataSource = ent.Varieties_Dismissalpermessions.ToList();
         dataGridView1.Columns["Varieties_Dismissalpermessions"].Visible = false;
         dataGridView2.Columns["DismissalPermission"].Visible            = false;
     }
     catch (Exception)
     {
         MessageBox.Show("something wrong in data entry");
     }
 }
Пример #18
0
        private void vName_SelectedIndexChanged(object sender, EventArgs e)
        {
            ent = new Cfirst();
            var v = from em in ent.Varieties where em.vName == vName.Text select em;

            foreach (var item in v)
            {
                storeName.Items.Clear();
                var so = from em in ent.stores where em.storeId == item.storeID select em;
                foreach (var i in so)
                {
                    storeName.Items.Add(i.name);
                }
            }
        }
Пример #19
0
        private void varietyName_SelectedIndexChanged(object sender, EventArgs e)
        {
            ent = new Cfirst();
            Varieties_supplypermessions vsp = (from em in ent.Varieties_supplypermessions
                                               where em.Varieties == varietyName.Text
                                               select em).First();
            int si = vsp.SupplyId;
            var sp = (from en in ent.supplyPermessions where en.SuplyId == si select en);

            storeName.Items.Clear();
            foreach (var item in sp)
            {
                storeName.Items.Add(item.Storename);
            }
        }
Пример #20
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");
     }
 }
Пример #21
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");
     }
 }
Пример #22
0
 private void btndelete_Click(object sender, EventArgs e)
 {
     try
     {
         ent = new Cfirst();
         int      id = int.Parse(customerId.Text);
         Customer cu = (from en in ent.Customers where en.customerId == id select en).FirstOrDefault();
         ent.Customers.Remove(cu);
         ent.SaveChanges();
         gridupdate();
     }
     catch (Exception)
     {
         MessageBox.Show("error in data entry");
     }
 }
Пример #23
0
 private void btndelete_Click(object sender, EventArgs e)
 {
     try
     {
         ent = new Cfirst();
         int      id = int.Parse(supplierId.Text);
         Supplier sp = (from en in ent.Suppliers where en.supplierId == id select en).FirstOrDefault();
         ent.Suppliers.Remove(sp);
         ent.SaveChanges();
         gridupdate();
     }
     catch (Exception)
     {
         MessageBox.Show("problem with data entry");
     }
 }
Пример #24
0
 private void btnAddV_Click(object sender, EventArgs e)
 {
     try
     {
         ent = new Cfirst();
         Varieties_supplypermessions vsp = new Varieties_supplypermessions();
         vsp.SupplyId   = int.Parse(supplyId.Text);
         vsp.Varieties  = variatiesName.Text;
         vsp.quantities = int.Parse(varietiesQuantity.Text);
         ent.Varieties_supplypermessions.Add(vsp);
         ent.SaveChanges();
     }
     catch (Exception)
     {
         MessageBox.Show("something went wrong in data entry");
     }
 }
Пример #25
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");
     }
 }
Пример #26
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");
     }
 }
Пример #27
0
 private void btnedit_Click(object sender, EventArgs e)
 {
     try
     {
         ent = new Cfirst();
         int      id = int.Parse(customerId.Text);
         Customer cu = (from em in ent.Customers where em.customerId == id select em).FirstOrDefault();
         cu.telephone = customerphone.Text == string.Empty ? cu.telephone : customerphone.Text;
         cu.fax       = customerFax.Text == string.Empty ? cu.fax : customerFax.Text;
         cu.Mobile    = customerMobile.Text == string.Empty ? cu.Mobile : customerMobile.Text;
         cu.Email     = customerEmail.Text == string.Empty ? cu.Email : customerEmail.Text;
         cu.Name      = name.Text == string.Empty ? cu.Name : name.Text;
         cu.website   = customerWebsite.Text == string.Empty ? cu.website : customerWebsite.Text;
         ent.SaveChanges();
         gridupdate();
     }
     catch (Exception)
     {
         MessageBox.Show("fault in data entry");
     }
 }
Пример #28
0
 private void btnedit_Click(object sender, EventArgs e)
 {
     try
     {
         ent = new Cfirst();
         int      id = int.Parse(supplierId.Text);
         Supplier sp = (from em in ent.Suppliers where em.supplierId == id select em).FirstOrDefault();
         sp.telephone = supplierphone.Text == string.Empty ? sp.telephone : supplierphone.Text;
         sp.fax       = supplierFax.Text == string.Empty ? sp.fax : supplierFax.Text;
         sp.Mobile    = supplierMobile.Text == string.Empty ? sp.Mobile : supplierMobile.Text;
         sp.Email     = supplierEmail.Text == string.Empty ? sp.Email : supplierEmail.Text;
         sp.Name      = name.Text == string.Empty ? sp.Name : name.Text;
         sp.website   = supplierWebsite.Text == string.Empty ? sp.website : supplierWebsite.Text;
         ent.SaveChanges();
         gridupdate();
     }
     catch (Exception)
     {
         MessageBox.Show("problem with data entry");
     }
 }
Пример #29
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");
            }
        }
Пример #30
0
        private void button2_Click(object sender, EventArgs e)
        {
            try
            {
                ent = new Cfirst();


                int id = int.Parse(supplyId.Text);
                supplyPermession sp = (from em in ent.supplyPermessions
                                       where
                                       em.SuplyId == id
                                       select em).FirstOrDefault();

                Varieties_supplypermessions vsp = (from en in ent.Varieties_supplypermessions
                                                   where
                                                   en.SupplyId == id
                                                   select en).FirstOrDefault();
                sp.supplieName = supplierName.Text == String.Empty ? sp.supplieName : supplierName.Text;
                vsp.Varieties  = variatiesName.Text == string.Empty ? vsp.Varieties : variatiesName.Text;
                vsp.quantities = varietiesQuantity.Text == string.Empty ? vsp.quantities :
                                 int.Parse(varietiesQuantity.Text);
                sp.expiry      = expiry.Text == string.Empty ? sp.expiry : expiry.Text;
                sp.supplieName = supplierName.Text == string.Empty ? sp.supplieName : supplierName.Text;
                sp.history     = permissionDate.Text == string.Empty ? sp.history :
                                 DateTime.Parse(permissionDate.Text);
                sp.ptoductionHistory = productionHistory.Text == string.Empty ? sp.ptoductionHistory :
                                       DateTime.Parse(productionHistory.Text);
                sp.Storename = storeName.Text == string.Empty ? sp.supplieName : storeName.Text;
                ent.SaveChanges();
                gridupdate();
            }
            catch (Exception)
            {
                MessageBox.Show("Somethig went wrong in Data Entry");
            }
        }