コード例 #1
0
 public ActionResult Edit(int id, StockSupplierModel model)
 {
     if (ModelState.IsValid)
     {
         try
         {
             // TODO: Add update logic here
             EHMSEntities ent = new EHMSEntities();
             var          obj = ent.SetupStockSuppliers.Where(x => x.StockSupplierID == model.StockSupplierID).SingleOrDefault();
             model.CreatedBy   = obj.CreatedBy;
             model.Status      = obj.Status;
             model.CreatedDate = obj.CreatedDate;
             AutoMapper.Mapper.Map(model, obj);
             ent.Entry(obj).State = System.Data.EntityState.Modified;
             int i = ent.SaveChanges();
             if (i != 0)
             {
                 TempData["success"] = HospitalManagementSystem.UtilityMessage.edit;
             }
         }
         catch
         {
             return(View(model));
         }
     }
     else
     {
         return(View(model));
     }
     return(RedirectToAction("Index"));
 }
コード例 #2
0
        public ActionResult Create(StockSupplierModel model)
        {
            int i;

            if (ModelState.IsValid)
            {
                try
                {
                    // TODO: Add insert logic here
                    i = pro.Insert(model);

                    if (i != 0)
                    {
                        TempData["success"] = HospitalManagementSystem.UtilityMessage.save;
                        return(RedirectToAction("Index"));
                    }


                    TempData["message"] = "Record with this name already exists in database!";
                    return(View(model));
                }
                catch
                {
                    return(View(model));
                }
            }
            else
            {
                return(View(model));
            }
        }
コード例 #3
0
        public ActionResult Report()
        {
            StockSupplierModel model = new StockSupplierModel();

            model.StockSupplierList = pro.GetList();
            return(View(model));
        }
コード例 #4
0
        //
        // GET: /StockSupplier/Edit/5

        public ActionResult Edit(int id)
        {
            EHMSEntities       ent   = new EHMSEntities();
            StockSupplierModel model = new StockSupplierModel();
            var obj = ent.SetupStockSuppliers.Where(x => x.StockSupplierID == id).SingleOrDefault();

            AutoMapper.Mapper.Map(obj, model);
            return(View(model));
        }
コード例 #5
0
        public int Insert(StockSupplierModel model)
        {
            using (EHMSEntities ent = new EHMSEntities())
            {
                if (ent.SetupStockSuppliers.Where(x => x.StockSupplierName == model.StockSupplierName).Any())
                {
                    return(0);
                }

                //first add in coa, Sundry Creditors add accgroupid =2 parenet id 1706 , hierarchycode 2.1253.1256 head level 5 isleave yes
                var Globj = new GL_AccSubGroups()
                {
                    AccGroupID      = 2,
                    AccSubGroupName = model.StockSupplierName,
                    ParentID        = 1706,
                    HeadLevel       = 5,
                    HierarchyCode   = "2.1253.1256.1706",
                    IsLeafLevel     = true,
                    Status          = true,
                    CreatedBy       = Utility.GetCurrentLoginUserId(),
                    CreatedDate     = DateTime.Today,
                    Remarks         = "Automatic from stock",
                };
                ent.GL_AccSubGroups.Add(Globj);
                ent.SaveChanges();

                var objToSave = AutoMapper.Mapper.Map <StockSupplierModel, SetupStockSupplier>(model);
                objToSave.Status        = true;
                objToSave.CreatedBy     = 1;
                objToSave.AccountHeadId = Globj.AccSubGruupID;
                objToSave.CreatedDate   = DateTime.Now;

                ent.SetupStockSuppliers.Add(objToSave);
                ent.SaveChanges();
            }
            return(1);
        }