Esempio n. 1
0
        public bool UpdateAsset(FA_Asset item)
        {
            string sql = " Update FA_Asset set  AssetItemId=@AssetItemId,PurchaseId=@PurchaseId, BillDate=@BillDate," +
                         " BillDateBs=@BillDateBs , BillNo=@BillNo , OpeningValue=@OpeningValue, PurchaseValue=@PurchaseValue, " +
                         " AssetUniqueCode=@AssetUniqueCode, Barcode=@Barcode, OrganizationId=@OrganizationId , BranchId=@BranchId ," +
                         " LocationId=@LocationId ,  Description=@Description ,  UsefulLife=@UsefulLife ,  AccessoryForAssetId=@AccessoryForAssetId ," +
                         " IsAccessory=@IsAccessory ,  IsDepreciationApplicable=@IsDepreciationApplicable , DepreciationStartDate=@DepreciationStartDate ," +
                         " DepreciationRemarks=@DepreciationRemarks , IsSold=@IsSold , SoldDate=@SoldDate ,  SoldValue=@SoldValue , IsScrap=@IsScrap ," +
                         " ScrapDate=@ScrapDate , ScrapRealizedValue=@ScrapRealizedValue ,LastUpdatedBy=@LastUpdatedBy , " +
                         " LastUpdatedDate=@LastUpdatedDate " +
                         " where AssetId= @AssetId";

            using (var db = DbHelper.GetDBConnection())
            {
                using (var trsn = new TransactionScope())
                {
                    //db.Execute(sql);
                    var lst = db.Execute(sql, item);
                    trsn.Complete();
                    db.Close();
                    if (lst > 0)
                    {
                        return(true);
                    }
                    else
                    {
                        return(false);
                    }
                }
            }
        }
Esempio n. 2
0
        public bool InsertAsset(FA_Asset item, string AssetUniqueCode3)
        {
            string sql = " Insert into  FA_Asset ( AssetItemId,PurchaseId, BillDate, BillDateBs , BillNo , OpeningValue, PurchaseValue, AssetUniqueCode,Barcode," +
                         " OrganizationId , BranchId ,  LocationId ,  Description ,  UsefulLife ,  AccessoryForAssetId ,  IsAccessory ,  IsDepreciationApplicable ," +
                         " DepreciationStartDate ,  DepreciationRemarks , IsSold , SoldDate ,  SoldValue , IsScrap , ScrapDate , ScrapRealizedValue ," +
                         " EnteredBy , EnteredDate , LastUpdatedBy ,  LastUpdatedDate ,  IsDeleted , DeletedBy , DeletedDate, CategoryId) " +
                         " values " +
                         "( @AssetItemId,@PurchaseId, @BillDate, @BillDateBs , @BillNo , @OpeningValue, @PurchaseValue,'" + AssetUniqueCode3 + "',@Barcode," +
                         " @OrganizationId , @BranchId ,  @LocationId ,  @Description ,  @UsefulLife ,  @AccessoryForAssetId ,  @IsAccessory ,  @IsDepreciationApplicable ," +
                         " @DepreciationStartDate ,  @DepreciationRemarks , @IsSold , @SoldDate ,  @SoldValue , @IsScrap , @ScrapDate , @ScrapRealizedValue ," +
                         " @EnteredBy , @EnteredDate , 0 ,  null ,  0 , 0 , null ,@CategoryId)";

            using (var db = DbHelper.GetDBConnection())
            {
                using (var trsn = new TransactionScope())
                {
                    //db.Execute(sql);
                    var lst = db.Execute(sql, item);
                    trsn.Complete();
                    db.Close();
                    if (lst > 0)
                    {
                        return(true);
                    }
                    else
                    {
                        return(false);
                    }
                }
            }
        }
        public ActionResult Create(FormCollection frm)
        {
            var ses               = sesrepo.GetSessionById((User as CustomPrincipal).UserId);
            int orgid             = ses.OrganizationId;
            int uid               = (User as CustomPrincipal).UserId;
            FA_AssetTransfer item = new FA_AssetTransfer();

            item.CategoryId = Convert.ToInt32(frm["CategoryId"]);
            item.AssetId    = Convert.ToInt32(frm["AssetItemId"]);
            FA_Asset assetid1 = db.getAssetId(item.AssetId);

            if (assetid1 != null)
            {
                int assetid = assetid1.AssetId;
            }
            item.OrganizationId  = string.IsNullOrEmpty(frm["OrganizationId1"]) ? 0 : Convert.ToInt32(frm["OrganizationId1"]);
            item.BranchId        = string.IsNullOrEmpty(frm["BranchId1"]) ? 0 : Convert.ToInt32(frm["BranchId1"]);
            item.LocationId      = string.IsNullOrEmpty(frm["LocationId1"]) ? 0 : Convert.ToInt32(frm["LocationId1"]);
            item.TransferDate    = DateTime.ParseExact(frm["TransferDate"], "yyyy-MM-dd", null);
            item.TransferDateBS  = frm["TransferDateBS"];
            item.Remarks         = frm["Remarks"];
            item.AssignedTo      = Convert.ToInt32(frm["AssignedToID"]);
            item.AssignedDate    = DateTime.ParseExact(frm["AssignedDate"], "yyyy-MM-dd", null);
            item.IsReceived      = null;
            item.ReceivedBy      = null;
            item.ReceivedDate    = null;
            item.EnteredBy       = uid;
            item.EnteredDate     = DateTime.Now;
            item.LastUpdatedBy   = null;
            item.LastUpdatedDate = null;
            item.IsDeleted       = false;
            item.DeletedBy       = null;
            item.DeletedDate     = null;
            //item.TransferId = 0;
            item.IsTransfered = 0;
            if (ModelState.IsValid)
            {
                db.InsertAssetTransfer(item);
                AssetTransferVM assetTransid = db.GetAssetTransferId();
                int             assetTraId   = assetTransid.AssetTransferId;
                int             assetId      = assetTransid.AssetId;
                db.UpdateAsset(assetTraId, assetId);
                AssetTransferVM PrevAssetTraId = db.GetAssetTransferSecondLastValue(assetTraId, assetId);
                if (PrevAssetTraId != null)
                {
                    int PrevAssetTransferId = PrevAssetTraId.AssetTransferId;
                    assetId = PrevAssetTraId.AssetId;
                    db.UpdateAssetTransfer(PrevAssetTransferId, assetId, assetTraId);
                }
                return(RedirectToAction("Index"));
            }
            ViewBag.OrganizationId = new SelectList(ddl.GetOrganizationList(), "Id", "Name", item.OrganizationId);
            //ViewBag.AssetItemId = new SelectList(ddl.GetAssetItemList(orgid), "Id", "Name", item.AssetItemId);
            ViewBag.BranchId   = new SelectList(ddl.GetBranchList(orgid), "Id", "Name", item.BranchId);
            ViewBag.LocationId = new SelectList(ddl.GetLocationList(orgid), "Id", "Name", item.LocationId);
            //ViewBag.AccessoryForAssetId = new SelectList(ddl.GetAssetList(orgid), "Id", "Name", item.AccessoryForAssetId);
            return(View(item));
        }
        // 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_Asset item  = db.GetAssetById((int)id);

            if (item == null)
            {
                return(HttpNotFound());
            }
            ViewBag.AssetItemId         = new SelectList(ddl.GetAssetItemList(orgid), "Id", "Name", item.AssetItemId);
            ViewBag.BranchId            = new SelectList(ddl.GetBranchList(orgid), "Id", "Name", item.BranchId);
            ViewBag.LocationId          = new SelectList(ddl.GetLocationList(orgid), "Id", "Name", item.LocationId);
            ViewBag.AccessoryForAssetId = new SelectList(ddl.GetAssetList(orgid), "Id", "Name", item.AccessoryForAssetId);
            return(View(item));
        }
        public ActionResult Create(FormCollection frm)
        {
            var      ses   = sesrepo.GetSessionById((User as CustomPrincipal).UserId);
            int      orgid = ses.OrganizationId;
            FA_Asset item  = new FA_Asset();

            item.AssetItemId = Convert.ToInt32(frm["AssetItemId"]);
            item.PurchaseId  = 0;
            item.BillDate    = DateTime.ParseExact(frm["BillDate"], "yyyy-MM-dd", null);

            item.BillDateBs    = frm["BillDateBs"];
            item.BillNo        = frm["BillNo"];
            item.OpeningValue  = Convert.ToDecimal(frm["OpeningValue"]);
            item.PurchaseValue = Convert.ToDecimal(frm["PurchaseValue"]);
            string AssetUniqueCode1 = string.IsNullOrEmpty(frm["AssetUniqueCode1"]) ? "" : frm["AssetUniqueCode1"];
            string AssetUniqueCode2 = string.IsNullOrEmpty(frm["AssetUniqueCode2"]) ? "" : frm["AssetUniqueCode2"];

            item.AssetUniqueCode = string.IsNullOrEmpty(frm["AssetUniqueCode"]) ? "" : frm["AssetUniqueCode"];

            string AssetUniqueCode3 = item.AssetUniqueCode + "-" + AssetUniqueCode1 + "-" + AssetUniqueCode2;

            item.Barcode         = string.IsNullOrEmpty(frm["Barcode"])?"": frm["Barcode"];
            item.OrganizationId  = orgid;
            item.BranchId        = string.IsNullOrEmpty(frm["BranchId"])?0:Convert.ToInt32(frm["BranchId"]);
            item.LocationId      = string.IsNullOrEmpty(frm["LocationId"]) ? 0 : Convert.ToInt32(frm["LocationId"]);
            item.AssetUniqueCode = frm["AssetUniqueCode"];
            item.Description     = frm["Description"];
            item.UsefulLife      = Convert.ToDecimal(frm["UsefulLife"]);
            item.CategoryId      = frm["CategoryId"];
            if (frm["IsAccessory"] == "Yes")
            {
                item.IsAccessory         = true;
                item.AccessoryForAssetId = Convert.ToInt32(frm["AccessoryForAssetId"]);
            }
            else
            {
                item.IsAccessory         = false;
                item.AccessoryForAssetId = 0;// Convert.ToInt32(frm["AccessoryForAssetId"]);
            }
            if (frm["IsDepreciationApplicable"] == "Yes")
            {
                item.IsDepreciationApplicable = true;
                item.DepreciationStartDate    = DateTime.ParseExact(frm["DepreciationStartDate"], "yyyy-MM-dd", null);
                item.DepreciationRemarks      = frm["DepreciationRemarks"];
            }
            else
            {
                item.IsDepreciationApplicable = false;
                item.DepreciationStartDate    = null;         // DateTime.ParseExact(frm["DepreciationStartDate"], "yyyy-MM-dd", null);
                item.DepreciationRemarks      = string.Empty; // frm["DepreciationRemarks"];
            }
            if (frm["IsSold"] == "Yes")
            {
                item.IsSold    = true;
                item.SoldDate  = DateTime.ParseExact(frm["SoldDate"], "yyyy-MM-dd", null);
                item.SoldValue = Convert.ToDecimal(frm["SoldValue"]);
            }
            else
            {
                item.IsSold    = false;
                item.SoldDate  = null; // DateTime.ParseExact(frm["SoldDate"], "yyyy-MM-dd", null);
                item.SoldValue = 0;    // Convert.ToDecimal(frm["SoldValue"]);
            }
            if (frm["IsScrap"] == "Yes")
            {
                item.IsScrap            = true;
                item.ScrapDate          = DateTime.ParseExact(frm["ScrapDate"], "yyyy-MM-dd", null);
                item.ScrapRealizedValue = Convert.ToDecimal(frm["ScrapRealizedValue"]);
            }
            else
            {
                item.IsScrap            = false;
                item.ScrapDate          = null; // DateTime.ParseExact(frm["SoldDate"], "yyyy-MM-dd", null);
                item.ScrapRealizedValue = 0;    // Convert.ToDecimal(frm["SoldValue"]);
            }
            item.IsDeleted   = false;
            item.EnteredBy   = (User as CustomPrincipal).UserId;
            item.EnteredDate = DateTime.Now;
            if (ModelState.IsValid)
            {
                db.InsertAsset(item, AssetUniqueCode3);
                return(RedirectToAction("Index"));
            }

            ViewBag.AssetItemId         = new SelectList(ddl.GetAssetItemList(orgid), "Id", "Name", item.AssetItemId);
            ViewBag.BranchId            = new SelectList(ddl.GetBranchList(orgid), "Id", "Name", item.BranchId);
            ViewBag.LocationId          = new SelectList(ddl.GetLocationList(orgid), "Id", "Name", item.LocationId);
            ViewBag.AccessoryForAssetId = new SelectList(ddl.GetAssetList(orgid), "Id", "Name", item.AccessoryForAssetId);
            return(View(item));
        }