コード例 #1
0
        public bool UpdateAssetCategory(FA_AssetCategory category)
        {
            string sql = " Update FA_AssetCategory set  CategoryName=@CategoryName, CategoryCode=@CategoryCode, DepreciationMethodId=@DepreciationMethodId," +
                         " DepreciationRate=@DepreciationRate, OrganizationId=@OrganizationId, " +
                         "LastUpdatedBy=@LastUpdatedBy, LastUpdatedDate=@LastUpdatedDate" +
                         " where AssetCategoryId= @AssetCategoryId";

            using (var db = DbHelper.GetDBConnection())
            {
                using (var trsn = new TransactionScope())
                {
                    //db.Execute(sql);
                    var lst = db.Execute(sql, category);
                    trsn.Complete();
                    db.Close();
                    if (lst > 0)
                    {
                        return(true);
                    }
                    else
                    {
                        return(false);
                    }
                }
            }
        }
コード例 #2
0
        public bool InsertAssetCategory(FA_AssetCategory category)
        {
            string sql = " Insert into  FA_AssetCategory ( CategoryName, CategoryCode, DepreciationMethodId, DepreciationRate, OrganizationId, " +
                         " EnteredBy, EnteredDate, LastUpdatedBy, LastUpdatedDate, IsDeleted, DeletedBy, DeletedDate) " +
                         " values " +
                         "( @CategoryName, @CategoryCode, @DepreciationMethodId, @DepreciationRate, @OrganizationId," +
                         "  @EnteredBy, @EnteredDate, 0, null, 0,0, null)";

            using (var db = DbHelper.GetDBConnection())
            {
                using (var trsn = new TransactionScope())
                {
                    //db.Execute(sql);
                    var lst = db.Execute(sql, category);
                    trsn.Complete();
                    db.Close();
                    if (lst > 0)
                    {
                        return(true);
                    }
                    else
                    {
                        return(false);
                    }
                }
            }
        }
コード例 #3
0
        // GET: Category/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            var ses   = sesrepo.GetSessionById((User as CustomPrincipal).UserId);
            int orgid = ses.OrganizationId;
            FA_AssetCategory category = db.GetAssetCategoryById((int)id);

            if (category == null)
            {
                return(HttpNotFound());
            }
            ViewBag.DepreciationMethodId = new SelectList(ddl.GetDepreciationList(orgid), "Id", "Name", category.DepreciationMethodId);
            return(View(category));
        }
コード例 #4
0
        public ActionResult Edit(FormCollection frm)
        {
            var ses   = sesrepo.GetSessionById((User as CustomPrincipal).UserId);
            int orgid = ses.OrganizationId;
            FA_AssetCategory category = db.GetAssetCategoryById(Convert.ToInt32(frm["AssetCategoryId"]));

            category.CategoryName         = frm["CategoryName"];
            category.CategoryCode         = frm["CategoryCode"];
            category.DepreciationMethodId = Convert.ToInt32(frm["DepreciationMethodId"]);
            category.DepreciationRate     = Convert.ToDecimal(frm["DepreciationRate"]);
            //category.IsDeleted = false;
            category.LastUpdatedBy   = (User as CustomPrincipal).UserId;
            category.LastUpdatedDate = DateTime.Now;
            if (ModelState.IsValid)
            {
                db.UpdateAssetCategory(category);
                return(RedirectToAction("Index"));
            }
            ViewBag.DepreciationMethodId = new SelectList(ddl.GetDepreciationList(orgid), "Id", "Name", category.DepreciationMethodId);
            return(View(category));
        }