コード例 #1
0
        public IHttpActionResult SaveUpdateCountWiseMachineSetup(object[] data)
        {
            vmPrdBallMachineSetup model = JsonConvert.DeserializeObject <vmPrdBallMachineSetup>(data[0].ToString());
            string result = string.Empty;

            try
            {
                result = objMachineSetService.SaveUpdateCountWiseMachineSetup(model);
            }
            catch (Exception e)
            {
                e.ToString();
            }

            return(Json(new
            {
                result
            }));
        }
コード例 #2
0
        public string SaveUpdateCountWiseMachineSetup(vmPrdBallMachineSetup model)
        {
            string result = string.Empty;

            using (TransactionScope transaction = new TransactionScope())
            {
                GFactory_EF_PrdBallMachineSetup = new PrdBallMachineSetup_EF();
                int BallMachineSetupID = 0;

                var BallMachineSetup = new PrdBallMachineSetup();
                var AllMachineSetup  = GFactory_EF_PrdBallMachineSetup.GetAll();
                try
                {
                    //using (_ctxCmn = new ERP_Entities())
                    //{
                    if (model.BallMachineSetupID > 0)
                    {
                        BallMachineSetup = AllMachineSetup.FirstOrDefault(x => x.BallMachineSetupID == model.BallMachineSetupID);
                        if (model.IsDeleted != false)
                        {
                            BallMachineSetup.CompanyID = (int)model.LCompanyID;
                            BallMachineSetup.DeleteBy  = (int)model.LUserID;
                            BallMachineSetup.IsDeleted = model.IsDeleted;
                            BallMachineSetup.DeleteOn  = DateTime.Now;
                            BallMachineSetup.DeletePc  = HostService.GetIP();
                        }
                        else
                        {
                            BallMachineSetup.Count     = (int)model.Count;
                            BallMachineSetup.Jog       = model.Jog;
                            BallMachineSetup.RFront    = model.RFront;
                            BallMachineSetup.RRear     = model.RRear;
                            BallMachineSetup.Agm       = model.Agm;
                            BallMachineSetup.Empty     = model.Empty;
                            BallMachineSetup.Speed     = model.Speed;
                            BallMachineSetup.CompanyID = (int)model.LCompanyID;
                            BallMachineSetup.UpdateBy  = (int)model.LUserID;
                            BallMachineSetup.UpdateOn  = DateTime.Now;
                            BallMachineSetup.UpdatePc  = HostService.GetIP();
                            BallMachineSetup.IsDeleted = false;
                        }

                        GFactory_EF_PrdBallMachineSetup.Update(BallMachineSetup);
                        GFactory_EF_PrdBallMachineSetup.Save();
                    }
                    else
                    {
                        BallMachineSetupID = Convert.ToInt16(GFactory_EF_PrdBallMachineSetup.getMaxID("PrdBallMachineSetup"));
                        BallMachineSetup   = new PrdBallMachineSetup
                        {
                            BallMachineSetupID = BallMachineSetupID,
                            Count     = (int)model.Count,
                            Jog       = model.Jog,
                            RFront    = model.RFront,
                            RRear     = model.RRear,
                            Agm       = model.Agm,
                            Empty     = model.Empty,
                            Speed     = model.Speed,
                            CompanyID = (int)model.LCompanyID,
                            CreateBy  = (int)model.LUserID,
                            CreateOn  = DateTime.Now,
                            CreatePc  = HostService.GetIP(),
                            IsDeleted = false
                        };

                        GFactory_EF_PrdBallMachineSetup.Insert(BallMachineSetup);
                        GFactory_EF_PrdBallMachineSetup.Save();
                        GFactory_EF_PrdBallMachineSetup.updateMaxID("PrdBallMachineSetup", Convert.ToInt64(BallMachineSetupID));
                    }

                    transaction.Complete();
                    result = BallMachineSetup.Count.ToString();
                }
                catch (Exception e)
                {
                    e.ToString();
                    result = "";
                }
            }
            return(result);
        }