示例#1
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");
            }
        }
示例#2
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");
            }
        }