public int Update(PRDChemProdReq model, int userId) { try { using (TransactionScope transaction = new TransactionScope()) { using (_context) { #region PI_Informaiton_Update var CurrentRequisition = (from p in _context.PRD_ChemProdReq.AsEnumerable() where p.RequisitionID == model.RequisitionID select p).FirstOrDefault(); CurrentRequisition.RequisitionCategory = model.RequisitionCategory; CurrentRequisition.RequisitionType = model.RequisitionType; CurrentRequisition.RequisitionFrom = model.RequisitionFrom; CurrentRequisition.RequisitionTo = model.RequisitionTo; CurrentRequisition.RequiredByTime = model.RequiredByTime; CurrentRequisition.ReqRaisedBy = 1; CurrentRequisition.ReqRaisedOn = DalCommon.SetDate((model.ReqRaisedOn).ToString()); if (model.RecipeFor == 0) { CurrentRequisition.RecipeFor = null; } else { CurrentRequisition.RecipeFor = model.RecipeFor; } if (model.RecipeID == 0) { CurrentRequisition.RecipeID = null; } else { CurrentRequisition.RecipeID = model.RecipeID; } //CurrentRequisition.RecipeFor = model.RecipeFor; //CurrentRequisition.RecipeID = model.RecipeID; CurrentRequisition.ArticleNo = model.ArticleNo; CurrentRequisition.Thickness = model.Thickness; if (model.ThicknessUnit != null) { CurrentRequisition.ThicknessUnit = model.ThicknessUnit; } CurrentRequisition.LeatherSize = model.LeatherSize; if (model.SizeUnit != null) { CurrentRequisition.SizeUnit = model.SizeUnit; } CurrentRequisition.Selection = model.Selection; CurrentRequisition.ProductionQty = model.ProductionQty; CurrentRequisition.ModifiedBy = userId; CurrentRequisition.ModifiedOn = DateTime.Now; _context.SaveChanges(); #endregion #region Update Requisition ItemList if (model.RequisitionItemList != null) { foreach (var item in model.RequisitionItemList) { var checkRequisitionItem = (from i in _context.PRD_ChemProdReqItem.AsEnumerable() where i.RequisitionItemID == item.RequisitionItemID select i).Any(); #region New_Requisition_Insertion if (!checkRequisitionItem) { PRD_ChemProdReqItem objItem = new PRD_ChemProdReqItem(); objItem.RequisitionID = model.RequisitionID; objItem.ItemID = Convert.ToInt32(item.ItemID); if (item.SupplierID == 0) { objItem.SupplierID = null; } else { objItem.SupplierID = item.SupplierID; } objItem.RequiredQty = item.RequiredQty; if (item.RequiredUnitName == null) { objItem.RequiredUnit = null; } else { objItem.RequiredUnit = DalCommon.GetUnitCode(item.RequiredUnitName); } objItem.RequsitionQty = Convert.ToDecimal(item.RequsitionQty); objItem.RequisitionUnit = DalCommon.GetUnitCode(item.RequisitionUnitName); if (item.PackSizeName == null) { objItem.PackSize = null; } else { objItem.PackSize = DalCommon.GetSizeCode(item.PackSizeName); } //objItem.PackSize = DalCommon.GetSizeCode(item.PackSizeName); if (item.SizeUnitName == null) { objItem.SizeUnit = null; } else { objItem.SizeUnit = DalCommon.GetUnitCode(item.SizeUnitName); } objItem.PackQty = item.PackQty; objItem.ApproveQty = item.ApproveQty; objItem.ApproveUnit = DalCommon.GetUnitCode(item.ApproveUnitName); //objItem.ManufacturerID = item.ManufacturerID; objItem.ItemSource = DalCommon.ReturnItemSource(item.ItemSource); objItem.SetOn = DateTime.Now; objItem.SetBy = userId; _context.PRD_ChemProdReqItem.Add(objItem); _context.SaveChanges(); } #endregion #region Existing_Requisition_Update else { var FoundRequisition = (from i in _context.PRD_ChemProdReqItem.AsEnumerable() where i.RequisitionItemID == item.RequisitionItemID select i).FirstOrDefault(); FoundRequisition.RequisitionID = model.RequisitionID; FoundRequisition.ItemID = Convert.ToInt32(item.ItemID); if (item.SupplierID == 0) { FoundRequisition.SupplierID = null; } else { FoundRequisition.SupplierID = item.SupplierID; } FoundRequisition.RequiredQty = item.RequiredQty; if (item.RequiredUnitName == null) { FoundRequisition.RequiredUnit = null; } else { FoundRequisition.RequiredUnit = DalCommon.GetUnitCode(item.RequiredUnitName); } FoundRequisition.RequsitionQty = Convert.ToDecimal(item.RequsitionQty); FoundRequisition.RequisitionUnit = DalCommon.GetUnitCode(item.RequisitionUnitName); if (item.PackSizeName == null) { FoundRequisition.PackSize = null; } else { FoundRequisition.PackSize = DalCommon.GetSizeCode(item.PackSizeName); } //objItem.PackSize = DalCommon.GetSizeCode(item.PackSizeName); if (item.SizeUnitName == null) { FoundRequisition.SizeUnit = null; } else { FoundRequisition.SizeUnit = DalCommon.GetUnitCode(item.SizeUnitName); } FoundRequisition.PackQty = item.PackQty; FoundRequisition.ApproveQty = item.ApproveQty; FoundRequisition.ApproveUnit = DalCommon.GetUnitCode(item.ApproveUnitName); FoundRequisition.ItemSource = DalCommon.ReturnItemSource(item.ItemSource); FoundRequisition.ModifiedOn = DateTime.Now; FoundRequisition.ModifiedBy = userId; _context.SaveChanges(); } #endregion } } #endregion } transaction.Complete(); } return(1); } catch (Exception e) { return(0); } }
public int Update(INVStoreTrans model, int userId) { try { using (TransactionScope transaction = new TransactionScope()) { using (_context) { #region Transaction_Informaiton_Update var CurrentTransaction = (from p in _context.INV_StoreTrans where p.TransactionID == model.TransactionID select p).FirstOrDefault(); CurrentTransaction.TransactionDate = DalCommon.SetDate(model.TransactionDate); CurrentTransaction.Remarks = model.Remark; CurrentTransaction.ModifiedBy = userId; CurrentTransaction.ModifiedOn = DateTime.Now; //_context.SaveChanges(); #endregion #region Update Requisition ItemList if (model.TransactionItemList != null) { foreach (var item in model.TransactionItemList) { var checkRequisitionItem = (from i in _context.INV_StoreTransItem where i.TransItemID == item.TransItemID select i).Any(); #region New_Item_Insertion if (!checkRequisitionItem) { INV_StoreTransItem objItem = new INV_StoreTransItem(); objItem.TransactionID = model.TransactionID; objItem.ItemID = item.ItemID; objItem.SupplierID = item.SupplierID; objItem.TransactionQty = item.IssueQty; objItem.TransactionUnit = DalCommon.GetUnitCode(item.IssueUnitName); objItem.PackSize = DalCommon.GetSizeCode(item.IssuePackSizeName); objItem.SizeUnit = DalCommon.GetUnitCode(item.IssueSizeUnitName); objItem.PackQty = item.IssuePackQty; objItem.SetOn = DateTime.Now; objItem.SetBy = userId; _context.INV_StoreTransItem.Add(objItem); //_context.SaveChanges(); } #endregion #region Existing_Item_Update else { var FoundItem = (from i in _context.INV_StoreTransItem where i.TransItemID == item.TransItemID select i).FirstOrDefault(); FoundItem.ItemID = item.ItemID; FoundItem.SupplierID = item.SupplierID; FoundItem.TransactionQty = item.IssueQty; FoundItem.TransactionUnit = DalCommon.GetUnitCode(item.IssueUnitName); FoundItem.PackSize = DalCommon.GetSizeCode(item.IssuePackSizeName); FoundItem.SizeUnit = DalCommon.GetUnitCode(item.IssueSizeUnitName); FoundItem.PackQty = item.IssuePackQty; FoundItem.ModifiedOn = DateTime.Now; FoundItem.ModifiedBy = userId; //_context.SaveChanges(); } #endregion } } #endregion _context.SaveChanges(); } transaction.Complete(); } return(1); } catch (Exception e) { return(0); } }
public int Save(PRDChemProdReq model, int userId, string pageUrl) { int CurrentRequisitionID = 0; try { using (TransactionScope transaction = new TransactionScope()) { using (_context) { var GetRequisitionNo = DalCommon.GetPreDefineNextCodeByUrl(pageUrl); if (GetRequisitionNo != null) { #region New_Requisition_Insert PRD_ChemProdReq objRequisition = new PRD_ChemProdReq(); objRequisition.RequisitionNo = GetRequisitionNo; objRequisition.RequisitionCategory = model.RequisitionCategory; objRequisition.RequisitionType = model.RequisitionType; objRequisition.RequisitionFrom = model.RequisitionFrom; objRequisition.RequisitionTo = model.RequisitionTo; objRequisition.RequiredByTime = model.RequiredByTime; objRequisition.ReqRaisedBy = userId; objRequisition.ReqRaisedOn = DalCommon.SetDate((model.ReqRaisedOn).ToString()); if (model.RecipeFor == 0) { objRequisition.RecipeFor = null; } else { objRequisition.RecipeFor = model.RecipeFor; } if (model.RecipeID == 0) { objRequisition.RecipeID = null; } else { objRequisition.RecipeID = model.RecipeID; } objRequisition.ArticleNo = model.ArticleNo; objRequisition.Thickness = model.Thickness; if (model.ThicknessUnit != null) { objRequisition.ThicknessUnit = model.ThicknessUnit; } objRequisition.LeatherSize = model.LeatherSize; if (model.SizeUnit != null) { objRequisition.SizeUnit = model.SizeUnit; } objRequisition.Selection = model.Selection; objRequisition.ProductionQty = model.ProductionQty; objRequisition.RequisitionState = "RNG"; objRequisition.RequisitionStatus = "PND"; objRequisition.RecordStatus = "NCF"; objRequisition.SetBy = userId; objRequisition.SetOn = DateTime.Now; //if (model.BuyerAddressID == 0) // objPI.BeneficiaryAddressID = null; //else // objPI.BeneficiaryAddressID = model.BuyerAddressID; _context.PRD_ChemProdReq.Add(objRequisition); _context.SaveChanges(); CurrentRequisitionID = objRequisition.RequisitionID; #endregion #region Item Insert if (model.RequisitionItemList != null) { foreach (var item in model.RequisitionItemList) { PRD_ChemProdReqItem objItem = new PRD_ChemProdReqItem(); objItem.RequisitionID = CurrentRequisitionID; objItem.ItemID = Convert.ToInt32(item.ItemID); if (item.SupplierID == 0) { objItem.SupplierID = null; } else { objItem.SupplierID = item.SupplierID; } //objItem.SupplierID = item.SupplierID; objItem.RequiredQty = item.RequiredQty; if (item.RequiredUnitName == null) { objItem.RequiredUnit = null; } else { objItem.RequiredUnit = DalCommon.GetUnitCode(item.RequiredUnitName); } objItem.RequsitionQty = Convert.ToDecimal(item.RequsitionQty); objItem.RequisitionUnit = DalCommon.GetUnitCode(item.RequisitionUnitName); if (item.PackSizeName == null) { objItem.PackSize = null; } else { objItem.PackSize = DalCommon.GetSizeCode(item.PackSizeName); } //objItem.PackSize = DalCommon.GetSizeCode(item.PackSizeName); if (item.SizeUnitName == null) { objItem.SizeUnit = null; } else { objItem.SizeUnit = DalCommon.GetUnitCode(item.SizeUnitName); } //objItem.SizeUnit = DalCommon.GetUnitCode(item.SizeUnitName); objItem.PackQty = item.PackQty; objItem.ApproveQty = item.ApproveQty; objItem.ApproveUnit = DalCommon.GetUnitCode(item.ApproveUnitName); //objItem.ManufacturerID = item.ManufacturerID; objItem.ItemSource = DalCommon.ReturnItemSource(item.ItemSource); objItem.SetOn = DateTime.Now; objItem.SetBy = userId; _context.PRD_ChemProdReqItem.Add(objItem); _context.SaveChanges(); } } #endregion } } transaction.Complete(); } return(CurrentRequisitionID); } catch (Exception e) { return(0); } }
public int Update(INVStoreTrans model, int userId) { try { using (TransactionScope transaction = new TransactionScope()) { using (_context) { #region Transaction_Informaiton_Update var CurrentTransaction = (from p in _context.INV_StoreTrans where p.TransactionID == model.TransactionID select p).FirstOrDefault(); if (model.AdjustmentType == "Addition") { CurrentTransaction.TransactionCategory = "RCV"; } else { CurrentTransaction.TransactionCategory = "ISU"; } if (model.PageName == "Adjustment") { CurrentTransaction.TransactionType = "ADI"; } else if (model.PageName == "InventoryAdjustment" & model.AdjustmentType == "Addition") { CurrentTransaction.TransactionType = "ADR"; } else if (model.PageName == "InventoryAdjustment" & model.AdjustmentType == "Subtraction") { CurrentTransaction.TransactionType = "ADI"; } else { CurrentTransaction.TransactionType = "ITP"; CurrentTransaction.TransactionTo = model.TransactionTo; } CurrentTransaction.Remarks = model.Remark; CurrentTransaction.TransactionDate = DalCommon.SetDate(model.TransactionDate); CurrentTransaction.ModifiedBy = userId; CurrentTransaction.ModifiedOn = DateTime.Now; //_context.SaveChanges(); #endregion #region Request Infromation Update if (model.PageName != "InventoryAdjustment") { if (model.PageName == "Adjustment") { var CurrentRequest = (from r in _context.INV_StoreTransRequest where r.TransactionID == model.TransactionID select r).FirstOrDefault(); CurrentRequest.ReqFromDate = DalCommon.SetDate(model.ReqFromDate); CurrentRequest.ReqToDate = DalCommon.SetDate(model.ReqToDate); CurrentRequest.ModifiedBy = userId; CurrentRequest.ModifiedOn = DateTime.Now; CurrentRequest.Remark = model.Remark; } else { var CurrentRequest = (from r in _context.INV_StoreTransRequest where r.TransactionID == model.TransactionID && r.RequisitionID == model.RefTransactionID select r).FirstOrDefault(); CurrentRequest.Remark = model.Remark; CurrentRequest.ModifiedBy = userId; CurrentRequest.ModifiedOn = DateTime.Now; } } #endregion #region Update Requisition ItemList if (model.InvStoreTransItemList != null) { foreach (var item in model.InvStoreTransItemList) { var checkRequisitionItem = (from i in _context.INV_StoreTransItem where i.TransItemID == item.TransItemID select i).Any(); #region New_Item_Insertion if (!checkRequisitionItem) { INV_StoreTransItem objItem = new INV_StoreTransItem(); objItem.TransactionID = model.TransactionID; objItem.ItemID = item.ItemID; if (item.SupplierID == 0) { objItem.SupplierID = null; } else { objItem.SupplierID = item.SupplierID; } objItem.TransactionQty = item.TransactionQty; objItem.TransactionUnit = DalCommon.GetUnitCode(item.TransactionUnitName); if (item.PackSizeName != null) { objItem.PackSize = DalCommon.GetSizeCode(item.PackSizeName); } if (item.SizeUnitName != null) { objItem.SizeUnit = DalCommon.GetUnitCode(item.SizeUnitName); } objItem.PackQty = item.PackQty; objItem.ItemSource = DalCommon.ReturnItemSource(item.ItemSource); objItem.SetOn = DateTime.Now; objItem.SetBy = userId; _context.INV_StoreTransItem.Add(objItem); //_context.SaveChanges(); } #endregion #region Existing_Item_Update else { var FoundItem = (from i in _context.INV_StoreTransItem where i.TransItemID == item.TransItemID select i).FirstOrDefault(); FoundItem.ItemID = item.ItemID; if (item.SupplierID == 0) { FoundItem.SupplierID = null; } else { FoundItem.SupplierID = item.SupplierID; } FoundItem.TransactionQty = item.TransactionQty; FoundItem.TransactionUnit = DalCommon.GetUnitCode(item.TransactionUnitName); if (item.PackSizeName != null) { FoundItem.PackSize = DalCommon.GetSizeCode(item.PackSizeName); } if (item.SizeUnitName != null) { FoundItem.SizeUnit = DalCommon.GetUnitCode(item.SizeUnitName); } FoundItem.PackQty = item.PackQty; FoundItem.ModifiedBy = userId; FoundItem.ModifiedOn = DateTime.Now; //_context.SaveChanges(); } #endregion } } #endregion _context.SaveChanges(); } transaction.Complete(); } return(1); } catch (Exception e) { return(0); } }
public long Save(INVStoreTrans model, int userId, string pageUrl) { long CurrentTransactionID = 0; try { using (TransactionScope transaction = new TransactionScope()) { using (_context) { var GetTransactionNo = DalCommon.GetPreDefineNextCodeByUrl(pageUrl); if (GetTransactionNo != null) { #region New_Transaction_Insert INV_StoreTrans objIssue = new INV_StoreTrans(); objIssue.TransactionNo = GetTransactionNo; objIssue.TransactionDate = DalCommon.SetDate(model.TransactionDate); objIssue.TransactionCategory = "ISU"; objIssue.TransactionType = "STI"; objIssue.TransactionFrom = model.IssueFrom; objIssue.TransactionTo = model.IssueTo; objIssue.TransactionStatus = "TRI"; objIssue.RecordStatus = "NCF"; objIssue.SetBy = userId; objIssue.SetOn = DateTime.Now; _context.INV_StoreTrans.Add(objIssue); _context.SaveChanges(); CurrentTransactionID = objIssue.TransactionID; #endregion #region Item Insert if (model.TransactionItemList != null) { foreach (var item in model.TransactionItemList) { INV_StoreTransItem objItem = new INV_StoreTransItem(); objItem.TransactionID = CurrentTransactionID; objItem.ItemID = item.ItemID; objItem.SupplierID = item.SupplierID; objItem.TransactionQty = item.IssueQty; objItem.TransactionUnit = DalCommon.GetUnitCode(item.IssueUnitName); objItem.PackSize = DalCommon.GetSizeCode(item.IssuePackSizeName); objItem.SizeUnit = DalCommon.GetUnitCode(item.IssueSizeUnitName); objItem.PackQty = item.IssuePackQty; //objItem.ItemSource = DalCommon.ReturnItemSource(item.ItemSource); objItem.SetOn = DateTime.Now; objItem.SetBy = userId; _context.INV_StoreTransItem.Add(objItem); //_context.SaveChanges(); } } #endregion } _context.SaveChanges(); } transaction.Complete(); } return(CurrentTransactionID); } catch (Exception e) { return(0); } }
public long Save(INVStoreTrans model, int userId, string pageUrl) { long CurrentTransactionID = 0; long CurrentRequestID = 0; using (TransactionScope transaction = new TransactionScope()) { try { using (_context) { string GetTransactionNo; if (model.PageName == "Adjustment") { GetTransactionNo = DalCommon.GetPreDefineNextCodeByUrl("ChemicalStockAdjustment/ChemicalStockAdjustment"); } else if (model.PageName == "InventoryAdjustment") { //Need Attention GetTransactionNo = DalCommon.GetPreDefineNextCodeByUrl("ChemicalStockAdjustment/ChemicalStockAdjustment"); } else { GetTransactionNo = DalCommon.GetPreDefineNextCodeByUrl(pageUrl); } if (GetTransactionNo != null) { #region New_Transaction_Insert INV_StoreTrans objIssue = new INV_StoreTrans(); objIssue.TransactionNo = GetTransactionNo; objIssue.TransactionDate = DalCommon.SetDate(model.TransactionDate); if (model.AdjustmentType == "Addition") { objIssue.TransactionCategory = "RCV"; } else { objIssue.TransactionCategory = "ISU"; } objIssue.TransactionFrom = model.TransactionFrom; if (model.PageName == "Adjustment") { objIssue.TransactionType = "ADI"; } else if (model.PageName == "InventoryAdjustment" & model.AdjustmentType == "Addition") { objIssue.TransactionType = "ADR"; } else if (model.PageName == "InventoryAdjustment" & model.AdjustmentType == "Subtraction") { objIssue.TransactionType = "ADI"; } else { objIssue.TransactionType = "ITP"; objIssue.TransactionTo = model.TransactionTo; } objIssue.RecordStatus = "NCF"; objIssue.TransactionState = "RNG"; objIssue.TransactionStatus = "TRI"; objIssue.SetBy = userId; objIssue.SetOn = DateTime.Now; _context.INV_StoreTrans.Add(objIssue); _context.SaveChanges(); CurrentTransactionID = objIssue.TransactionID; #endregion #region New Transaction Request Insert if (model.PageName != "InventoryAdjustment") { var objRequest = new INV_StoreTransRequest(); objRequest.TransRequestNo = DalCommon.GetPreDefineNextCodeByUrl(pageUrl); objRequest.TransactionID = CurrentTransactionID; if (model.PageName == "Adjustment") { objRequest.ReqFromDate = DalCommon.SetDate(model.ReqFromDate); objRequest.ReqToDate = DalCommon.SetDate(model.ReqToDate); } else { objRequest.RequisitionID = Convert.ToInt32(model.RefTransactionID); objRequest.RequestNo = model.RefTransactionNo; } objRequest.Remark = model.Remark; objRequest.SetBy = userId; objRequest.SetOn = DateTime.Now; _context.INV_StoreTransRequest.Add(objRequest); _context.SaveChanges(); CurrentRequestID = objRequest.TransRequestID; } #endregion #region Item Insert if (model.InvStoreTransItemList != null) { foreach (var item in model.InvStoreTransItemList) { INV_StoreTransItem objItem = new INV_StoreTransItem(); objItem.TransactionID = CurrentTransactionID; if (model.PageName != "InventoryAdjustment") { objItem.TransRequestID = CurrentRequestID; } objItem.ItemID = item.ItemID; if (item.SupplierID == 0) { objItem.SupplierID = null; } else { objItem.SupplierID = item.SupplierID; } objItem.TransactionQty = item.TransactionQty; objItem.TransactionUnit = DalCommon.GetUnitCode(item.TransactionUnitName); if (item.PackSizeName != null) { objItem.PackSize = DalCommon.GetSizeCode(item.PackSizeName); } if (item.SizeUnitName != null) { objItem.SizeUnit = DalCommon.GetUnitCode(item.SizeUnitName); } objItem.PackQty = item.PackQty; objItem.SetOn = DateTime.Now; objItem.SetBy = userId; _context.INV_StoreTransItem.Add(objItem); //_context.SaveChanges(); } } #endregion } _context.SaveChanges(); } transaction.Complete(); } catch (Exception e) { CurrentTransactionID = 0; return(CurrentTransactionID); } } return(CurrentTransactionID); }
public long SavePurchaseInformation(PurchaseReceive model, int userId) { long CurrentPurchaseID = 0; try { using (TransactionScope transaction = new TransactionScope()) { #region New_Purchase_Insert using (_context) { Prq_Purchase objPurchase = new Prq_Purchase(); //Random r = new Random(); //objPurchase.PurchaseNo = r.Next().ToString(); objPurchase.PurchaseNo = DalCommon.GetPreDefineNextCodeByUrl("Purchase/Purchase"); objPurchase.SupplierID = Convert.ToInt16(model.SupplierID); objPurchase.SupplierAddressID = Convert.ToInt16(model.SupplierAddressID); objPurchase.PurchaseCategory = model.PurchaseCategory; objPurchase.PurchaseType = model.PurchaseType; objPurchase.PurchaseYear = model.PurchaseYear; objPurchase.PurchaseDate = DalCommon.SetDate(model.PurchaseDate); objPurchase.PurchaseNote = model.PurchaseNote; objPurchase.RecordStatus = "NCF"; objPurchase.SetOn = DateTime.Now; objPurchase.SetBy = userId; _context.Prq_Purchase.Add(objPurchase); _context.SaveChanges(); CurrentPurchaseID = objPurchase.PurchaseID; if (model.ChallanList != null) { Prq_PurchaseChallan objChallan = new Prq_PurchaseChallan(); objChallan.ChallanNo = model.ChallanList.FirstOrDefault().ChallanNo; objChallan.PurchaseID = CurrentPurchaseID; objChallan.SourceID = model.ChallanList.FirstOrDefault().SourceID; objChallan.LocationID = model.ChallanList.FirstOrDefault().LocationID; objChallan.ReceiveStore = DalCommon.GetStoreCode(model.ChallanList.FirstOrDefault().ReceiveStore); objChallan.ChallanCategory = model.ChallanList.FirstOrDefault().ChallanCategory; objChallan.ChallanNote = model.ChallanList.FirstOrDefault().ChallanNote; objChallan.ChallanDate = Convert.ToDateTime(model.ChallanList.FirstOrDefault().ChallanDate); objChallan.RecordStatus = "NCF"; objChallan.SetOn = DateTime.Now; objChallan.SetBy = userId; _context.Prq_PurchaseChallan.Add(objChallan); _context.SaveChanges(); var CurrentChallanNo = objChallan.ChallanID; if (model.ChallanItemList != null) { foreach (var ChallanItem in model.ChallanItemList) { Prq_PurchaseChallanItem objPurchaseChallanItem = new Prq_PurchaseChallanItem(); objPurchaseChallanItem.ChallanID = CurrentChallanNo; objPurchaseChallanItem.ItemCategory = "Leather"; objPurchaseChallanItem.ItemTypeID = DalCommon.GetItemTypeCode(ChallanItem.ItemTypeID); objPurchaseChallanItem.ItemSizeID = DalCommon.GetSizeCode(ChallanItem.ItemSizeID); objPurchaseChallanItem.Description = ChallanItem.Description; objPurchaseChallanItem.UnitID = DalCommon.GetUnitCode(ChallanItem.UnitID); objPurchaseChallanItem.ChallanQty = ChallanItem.ChallanQty; objPurchaseChallanItem.ReceiveQty = ChallanItem.ReceiveQty; objPurchaseChallanItem.Remark = ChallanItem.Remark; objPurchaseChallanItem.RecordStatus = "NCF"; objPurchaseChallanItem.SetBy = userId; objPurchaseChallanItem.SetOn = DateTime.Now; _context.Prq_PurchaseChallanItem.Add(objPurchaseChallanItem); _context.SaveChanges(); } } } } #endregion transaction.Complete(); } return(CurrentPurchaseID); } catch (Exception e) { return(CurrentPurchaseID); } }
public int UpdatePurchaseInformation(PurchaseReceive model, int userId) { long CurrentChallanNo = 0; try { using (TransactionScope transaction = new TransactionScope()) { using (_context) { #region Purchase_Informaiton_Update var currentPurchase = (from p in _context.Prq_Purchase.AsEnumerable() where p.PurchaseID == Convert.ToInt64(model.PurchaseID) select p).FirstOrDefault(); if (currentPurchase.RecordStatus != "CNF") { currentPurchase.SupplierID = Convert.ToInt32(model.SupplierID); currentPurchase.SupplierAddressID = Convert.ToInt32(model.SupplierAddressID); currentPurchase.PurchaseCategory = model.PurchaseCategory; currentPurchase.PurchaseType = model.PurchaseType; currentPurchase.PurchaseYear = model.PurchaseYear; currentPurchase.PurchaseNote = model.PurchaseNote; currentPurchase.RecordStatus = "NCF"; currentPurchase.PurchaseDate = DalCommon.SetDate(model.PurchaseDate); currentPurchase.SetBy = userId; currentPurchase.SetOn = DateTime.Now; _context.SaveChanges(); } #endregion #region Update_Challan_Information if (model.ChallanList != null) { foreach (var challan in model.ChallanList) { #region New_Challan_Insertion if (challan.ChallanID == 0) { Prq_PurchaseChallan objChallan = new Prq_PurchaseChallan(); objChallan.ChallanNo = challan.ChallanNo; objChallan.PurchaseID = Convert.ToInt32(model.PurchaseID); objChallan.SourceID = challan.SourceID; objChallan.LocationID = challan.LocationID; objChallan.ReceiveStore = DalCommon.GetStoreCode(challan.ReceiveStore); objChallan.ChallanCategory = challan.ChallanCategory; objChallan.ChallanNote = challan.ChallanNote; objChallan.ChallanDate = Convert.ToDateTime(challan.ChallanDate); objChallan.RecordStatus = "NCF"; objChallan.SetOn = DateTime.Now; objChallan.SetBy = userId;; _context.Prq_PurchaseChallan.Add(objChallan); _context.SaveChanges(); CurrentChallanNo = objChallan.ChallanID; } #endregion #region Existing_Challan_Update else if (challan.ChallanID != 0 && challan.RecordStatus != "CNF" && challan.RecordStatus != "Confirmed") { var currentChallan = (from c in _context.Prq_PurchaseChallan.AsEnumerable() where c.ChallanID == challan.ChallanID select c).FirstOrDefault(); currentChallan.ChallanNo = challan.ChallanNo; //currentChallan.PurchaseID = Convert.ToInt32(model.PurchaseID); currentChallan.SourceID = challan.SourceID; currentChallan.LocationID = challan.LocationID; currentChallan.ReceiveStore = DalCommon.GetStoreCode(challan.ReceiveStore); currentChallan.ChallanCategory = challan.ChallanCategory; currentChallan.ChallanNote = challan.ChallanNote; try { //var GridChallanDate = Convert.ToDateTime(challan.ChallanDate).Date.ToString("dd/MM/yyyy"); //currentChallan.ChallanDate = DalCommon.SetDate(GridChallanDate); var GridChallanDate = challan.ChallanDate.Contains("/") ? challan.ChallanDate : Convert.ToDateTime(challan.ChallanDate).ToString("dd/MM/yyyy"); //var GridChallanDate = Convert.ToDateTime(challan.ChallanDate).ToString().Contains("/") ? challan.ChallanDate : Convert.ToDateTime(challan.ChallanDate).ToString("dd/MM/yyyy"); currentChallan.ChallanDate = DalCommon.SetDate(GridChallanDate); } catch { var GridChallanDate = Convert.ToDateTime(challan.ChallanDate).Date.ToString("dd/MM/yyyy"); currentChallan.ChallanDate = DalCommon.SetDate(GridChallanDate); //currentChallan.ChallanDate = DalCommon.SetDate(challan.ChallanDate); } currentChallan.RecordStatus = "NCF"; currentChallan.SetOn = DateTime.Now; currentChallan.SetBy = userId; _context.SaveChanges(); } #endregion } } #endregion #region To_Find_ChallanID_For_Items_If_Any if (model.ChallanItemList != null) { foreach (var challanItem in model.ChallanItemList) { if (challanItem.ChallanID != 0) { CurrentChallanNo = challanItem.ChallanID; break; } } } #endregion #region Update_Challan_Item_Information if (model.ChallanItemList != null) { foreach (var challanItem in model.ChallanItemList) { #region New_Challan_Item_Insertion if (challanItem.ChallanItemID == 0) { Prq_PurchaseChallanItem objPurchaseChallanItem = new Prq_PurchaseChallanItem(); objPurchaseChallanItem.ChallanID = CurrentChallanNo; objPurchaseChallanItem.ItemCategory = "Leather"; objPurchaseChallanItem.ItemTypeID = DalCommon.GetItemTypeCode(challanItem.ItemTypeID); objPurchaseChallanItem.ItemSizeID = DalCommon.GetSizeCode(challanItem.ItemSizeID); objPurchaseChallanItem.Description = challanItem.Description; objPurchaseChallanItem.UnitID = DalCommon.GetUnitCode(challanItem.UnitID); objPurchaseChallanItem.ChallanQty = challanItem.ChallanQty; objPurchaseChallanItem.ReceiveQty = challanItem.ReceiveQty; objPurchaseChallanItem.Remark = challanItem.Remark; objPurchaseChallanItem.RecordStatus = "NCF"; objPurchaseChallanItem.SetBy = userId;; objPurchaseChallanItem.SetOn = DateTime.Now; _context.Prq_PurchaseChallanItem.Add(objPurchaseChallanItem); _context.SaveChanges(); } #endregion #region Update_Existing_Challan_Item else if (challanItem.ChallanItemID != 0 && challanItem.RecordStatus != "CNF" && challanItem.RecordStatus != "Confirmed") { var currentChallanItem = (from c in _context.Prq_PurchaseChallanItem.AsEnumerable() where c.ChallanItemID == challanItem.ChallanItemID select c).FirstOrDefault(); currentChallanItem.ItemSizeID = DalCommon.GetSizeCode(challanItem.ItemSizeID); currentChallanItem.ItemTypeID = DalCommon.GetItemTypeCode(challanItem.ItemTypeID); currentChallanItem.UnitID = DalCommon.GetUnitCode(challanItem.UnitID); currentChallanItem.Description = challanItem.Description; currentChallanItem.ChallanQty = challanItem.ChallanQty; currentChallanItem.ReceiveQty = challanItem.ReceiveQty; currentChallanItem.Remark = challanItem.Remark; _context.SaveChanges(); } #endregion } } #endregion } transaction.Complete(); } return(1); } catch (Exception e) { return(0); } }
public int Update(PRQChemicalPI model, int userId) { try { using (TransactionScope transaction = new TransactionScope()) { using (_context) { #region PI_Informaiton_Update var currentPI = (from p in _context.PRQ_ChemicalPI.AsEnumerable() where p.PIID == model.PIID select p).FirstOrDefault(); currentPI.PINo = model.PINo; currentPI.PIDate = DalCommon.SetDate(model.PIDate); currentPI.PICategory = model.PICategory; currentPI.OrderID = model.OrderID; currentPI.OrderNo = model.OrderNo; currentPI.PIReceiveDate = DateTime.Now; if (model.SupplierID == 0) { currentPI.SupplierID = null; } else { currentPI.SupplierID = model.SupplierID; } if (model.LocalAgent == 0) { currentPI.LocalAgent = null; } else { currentPI.LocalAgent = model.LocalAgent; } if (model.ForeignAgent == 0) { currentPI.ForeignAgent = null; } else { currentPI.ForeignAgent = model.ForeignAgent; } if (model.BuyerID == 0) { currentPI.PIBeneficiary = null; } else { currentPI.PIBeneficiary = model.BuyerID; } if (model.BuyerAddressID == 0) { currentPI.BeneficiaryAddressID = null; } else { currentPI.BeneficiaryAddressID = model.BuyerAddressID; } if (model.PICurrency == 0) { currentPI.PICurrency = null; } else { currentPI.PICurrency = model.PICurrency; } if (model.ExchangeCurrency == 0) { currentPI.ExchangeCurrency = null; } else { currentPI.ExchangeCurrency = model.ExchangeCurrency; } if (model.ExchangeRate == 0) { currentPI.ExchangeRate = null; } else { currentPI.ExchangeRate = model.ExchangeRate; } if (model.ExchangeValue == 0) { currentPI.ExchangeValue = null; } else { currentPI.ExchangeValue = model.ExchangeValue; } currentPI.PaymentTerm = model.PaymentTerm; currentPI.PaymentMode = model.PaymentMode; currentPI.DeferredDays = model.DeferredDays; if (model.CountryOforigin == 0) { currentPI.CountryOforigin = null; } else { currentPI.CountryOforigin = model.CountryOforigin; } if (model.BeneficiaryBank == 0) { currentPI.BeneficiaryBank = null; } else { currentPI.BeneficiaryBank = model.BeneficiaryBank; } currentPI.FreightCharge = model.FreightCharge; currentPI.FreightChargeExtra = model.FreightChargeExtra; //if (model.AdvisingBank == 0) // currentPI.AdvisingBank = null; //else // currentPI.AdvisingBank = model.AdvisingBank; currentPI.DeliveryTerm = model.DeliveryTerm; currentPI.DeliveryMode = model.DeliveryMode; if (model.PortofLoading == 0) { currentPI.PortofLoading = null; } else { currentPI.PortofLoading = model.PortofLoading; } if (model.PortofDischarge == 0) { currentPI.PortofDischarge = null; } else { currentPI.PortofDischarge = model.PortofDischarge; } currentPI.Transshipment = model.Transshipment; currentPI.PartialShipment = model.PartialShipment; currentPI.GoodDelivery = model.GoodDelivery; currentPI.ShippingMark = model.ShippingMark; if (model.ExpectedShipmentTime == 0) { currentPI.ExpectedShipmentTime = null; } else { currentPI.ExpectedShipmentTime = model.ExpectedShipmentTime; } currentPI.Packing = model.Packing; currentPI.PreShipmentIns = model.PreShipmentIns; if (model.OfferValidityDays == 0) { currentPI.OfferValidityDays = null; } else { currentPI.OfferValidityDays = model.OfferValidityDays; } currentPI.OfferValidityNote = model.OfferValidityNote; currentPI.RecordStatus = "NCF"; currentPI.ModifiedBy = userId; currentPI.ModifiedOn = DateTime.Now; _context.SaveChanges(); #endregion #region Update_PIItemList if (model.PIItemList != null) { foreach (var PIItem in model.PIItemList) { var checkPIItem = (from i in _context.PRQ_ChemicalPIItem.AsEnumerable() where i.PIItemID == PIItem.PIItemID select i).Any(); #region New_Requisition_Insertion if (!checkPIItem) { PRQ_ChemicalPIItem objItem = new PRQ_ChemicalPIItem(); objItem.PIID = model.PIID; objItem.ItemID = PIItem.ItemID; objItem.OrderQty = PIItem.OrderQty; objItem.OrderUnit = DalCommon.GetUnitCode(PIItem.OrderUnitName); objItem.PackSize = DalCommon.GetSizeCode(PIItem.PackSizeName); objItem.SizeUnit = DalCommon.GetUnitCode(PIItem.SizeUnitName); objItem.PackQty = PIItem.PackQty; objItem.PIQty = Convert.ToDecimal(PIItem.PackSizeName) * PIItem.PackQty; objItem.PIUnit = DalCommon.GetUnitCode(PIItem.PIUnitName); objItem.PIUnitPrice = PIItem.PIUnitPrice; objItem.PITotalPrice = Convert.ToDecimal(PIItem.PackSizeName) * PIItem.PackQty * PIItem.PIUnitPrice; objItem.SupplierID = PIItem.SupplierID; //objItem.ManufacturerID = item.ManufacturerID; objItem.ItemSource = PIItem.ItemSource; objItem.SetOn = DateTime.Now; objItem.SetBy = userId; _context.PRQ_ChemicalPIItem.Add(objItem); _context.SaveChanges(); } #endregion #region Existing_Requisition_Update else { var FoundPI = (from i in _context.PRQ_ChemicalPIItem.AsEnumerable() where i.PIItemID == PIItem.PIItemID select i).FirstOrDefault(); FoundPI.PIID = model.PIID; FoundPI.ItemID = PIItem.ItemID; FoundPI.OrderQty = PIItem.OrderQty; FoundPI.OrderUnit = DalCommon.GetUnitCode(PIItem.OrderUnitName); FoundPI.PackSize = DalCommon.GetSizeCode(PIItem.PackSizeName); FoundPI.SizeUnit = DalCommon.GetUnitCode(PIItem.SizeUnitName); FoundPI.PackQty = PIItem.PackQty; FoundPI.PIQty = Convert.ToDecimal(PIItem.PackSizeName) * PIItem.PackQty; FoundPI.PIUnit = DalCommon.GetUnitCode(PIItem.PIUnitName); FoundPI.PIUnitPrice = PIItem.PIUnitPrice; FoundPI.PITotalPrice = Convert.ToDecimal(PIItem.PackSizeName) * PIItem.PackQty * PIItem.PIUnitPrice; _context.SaveChanges(); } #endregion } } #endregion } transaction.Complete(); } return(1); } catch (Exception e) { return(0); } }
public int Save(PRQChemicalPI model, int userId, string pageUrl) { int CurrentPIID = 0; try { using (TransactionScope transaction = new TransactionScope()) { using (_context) { #region New_PI_Insert PRQ_ChemicalPI objPI = new PRQ_ChemicalPI(); objPI.PINo = model.PINo; objPI.PIDate = DalCommon.SetDate(model.PIDate); objPI.PICategory = model.PICategory; objPI.OrderID = model.OrderID; objPI.OrderNo = model.OrderNo; objPI.PIReceiveDate = DateTime.Now; if (model.SupplierID == 0) { objPI.SupplierID = null; } else { objPI.SupplierID = model.SupplierID; } if (model.LocalAgent == 0) { objPI.LocalAgent = null; } else { objPI.LocalAgent = model.LocalAgent; } if (model.ForeignAgent == 0) { objPI.ForeignAgent = null; } else { objPI.ForeignAgent = model.ForeignAgent; } if (model.BuyerID == 0) { objPI.PIBeneficiary = null; } else { objPI.PIBeneficiary = model.BuyerID; } if (model.BuyerAddressID == 0) { objPI.BeneficiaryAddressID = null; } else { objPI.BeneficiaryAddressID = model.BuyerAddressID; } if (model.PICurrency == 0) { objPI.PICurrency = null; } else { objPI.PICurrency = model.PICurrency; } if (model.ExchangeCurrency == 0) { objPI.ExchangeCurrency = null; } else { objPI.ExchangeCurrency = model.ExchangeCurrency; } if (model.ExchangeRate == 0) { objPI.ExchangeRate = null; } else { objPI.ExchangeRate = model.ExchangeRate; } if (model.ExchangeValue == 0) { objPI.ExchangeValue = null; } else { objPI.ExchangeValue = model.ExchangeValue; } objPI.PaymentTerm = model.PaymentTerm; objPI.PaymentMode = model.PaymentMode; objPI.DeferredDays = model.DeferredDays; if (model.CountryOforigin == 0) { objPI.CountryOforigin = null; } else { objPI.CountryOforigin = model.CountryOforigin; } if (model.BeneficiaryBank == 0) { objPI.BeneficiaryBank = null; } else { objPI.BeneficiaryBank = model.BeneficiaryBank; } //if (model.AdvisingBank == 0) // objPI.AdvisingBank = null; //else // objPI.AdvisingBank = model.AdvisingBank; objPI.FreightCharge = model.FreightCharge; objPI.FreightChargeExtra = model.FreightChargeExtra; objPI.DeliveryTerm = model.DeliveryTerm; objPI.DeliveryMode = model.DeliveryMode; if (model.PortofLoading == 0) { objPI.PortofLoading = null; } else { objPI.PortofLoading = model.PortofLoading; } if (model.PortofDischarge == 0) { objPI.PortofDischarge = null; } else { objPI.PortofDischarge = model.PortofDischarge; } objPI.Transshipment = model.Transshipment; objPI.PartialShipment = model.PartialShipment; objPI.GoodDelivery = model.GoodDelivery; objPI.ShippingMark = model.ShippingMark; if (model.ExpectedShipmentTime == 0) { objPI.ExpectedShipmentTime = null; } else { objPI.ExpectedShipmentTime = model.ExpectedShipmentTime; } objPI.Packing = model.Packing; objPI.PreShipmentIns = model.PreShipmentIns; if (model.OfferValidityDays == 0) { objPI.OfferValidityDays = null; } else { objPI.OfferValidityDays = model.OfferValidityDays; } objPI.OfferValidityNote = model.OfferValidityNote; objPI.RecordStatus = "NCF"; objPI.SetBy = userId; objPI.SetOn = DateTime.Now; objPI.PIStatus = "ODDN"; objPI.PIState = "RNG"; //objPI.PIReceiveDate=?? //objPI.PINote=?? //objPI.RunningStatus= ?? //objPI.CostIndicator= ?? _context.PRQ_ChemicalPI.Add(objPI); _context.SaveChanges(); CurrentPIID = objPI.PIID; #endregion #region Item Insert if (model.PIItemList != null) { foreach (var item in model.PIItemList) { PRQ_ChemicalPIItem objItem = new PRQ_ChemicalPIItem(); objItem.PIID = CurrentPIID; objItem.ItemID = item.ItemID; objItem.OrderQty = item.OrderQty; objItem.OrderUnit = DalCommon.GetUnitCode(item.OrderUnitName); objItem.PackSize = DalCommon.GetSizeCode(item.PackSizeName); objItem.SizeUnit = DalCommon.GetUnitCode(item.SizeUnitName); objItem.PackQty = item.PackQty; objItem.PIQty = Convert.ToDecimal(item.PackSizeName) * item.PackQty; objItem.PIUnit = DalCommon.GetUnitCode(item.PIUnitName); objItem.PIUnitPrice = item.PIUnitPrice; objItem.PITotalPrice = Convert.ToDecimal(item.PackSizeName) * item.PackQty * item.PIUnitPrice; objItem.SupplierID = item.SupplierID; //objItem.ManufacturerID = item.ManufacturerID; objItem.ItemSource = item.ItemSource; objItem.SetOn = DateTime.Now; objItem.SetBy = userId; _context.PRQ_ChemicalPIItem.Add(objItem); _context.SaveChanges(); } } #endregion } transaction.Complete(); } return(CurrentPIID); } catch (Exception e) { return(CurrentPIID); } }