コード例 #1
0
        public static int fnSaveCASToDB(Cas CS)
        {
            using (var db = new EF.CMCSQL03Entities())
            {
                if (CS.casid == -1)
                {
                    var newrec = new EF.tblCAS();
                    db.tblCAS.Add(newrec);
                    db.SaveChanges();
                    CS.casid = newrec.CASID;
                }

                var q = (from t in db.tblCAS
                         where t.CASID == CS.casid
                         select t).FirstOrDefault();

                q.ProductDetailID = CS.productdetailid;
                q.CasNumber = CS.casnumber;
                q.ChemicalName = CS.chemicalname;
                q.Percentage = CS.percentage;
                q.RestrictedQty = CS.restrictedqty;
                q.RestrictedAmount = CS.restrictedamount;
                q.ReportableQty = CS.reportableqty;
                q.ReportableAmount = CS.reportableamount;
                q.LessThan = CS.lessthan;
                q.ExcludeFromLabel = CS.excludefromlabel;

                db.SaveChanges();

                return q.CASID;
            }
        }
コード例 #2
0
        public static Cas fnCreateCAS(int id)
        {
            Cas CS = new Cas();
            CS.casid = -1;
            CS.productdetailid = id;

            return CS;
        }
コード例 #3
0
        public static Cas fnGetCAS(int id)
        {
            Cas CS = new Cas();
            using (var db = new EF.CMCSQL03Entities())
            {
                var q = (from t in db.tblCAS
                         where t.CASID == id
                         select t).FirstOrDefault();

                CS.casid = q.CASID;
                CS.productdetailid = q.ProductDetailID;
                CS.casnumber = q.CasNumber;
                CS.chemicalname = q.ChemicalName;
                CS.percentage = q.Percentage;
                CS.restrictedqty = q.RestrictedQty;
                CS.restrictedamount = q.RestrictedAmount;
                CS.reportableqty = q.ReportableQty;
                CS.reportableamount = q.ReportableAmount;
                CS.lessthan = q.LessThan;
                CS.excludefromlabel = q.ExcludeFromLabel;

                return CS;
            }
        }
コード例 #4
0
 public ActionResult SaveCAS(Cas CS)
 {
     int pk = ProductsService.fnSaveCASToDB(CS);
     return Content("Data Updated at " + DateTime.Now);
 }