public List <PurchaseInvoiceEntity> GetPurchaseInvoiceDetails(int psID) { string pandsId = Convert.ToString(psID); try { List <PurchaseInvoiceEntity> lstCodes = new List <PurchaseInvoiceEntity>(); using (SDNProductDBEntities objprodEntities = new SDNProductDBEntities()) { lstCodes = (from pi in objprodEntities.PurchaseInvoices join pid in objprodEntities.PurchaseInvoiceDetails on pi.ID equals pid.PI_ID where pid.PI_No == pandsId select new PurchaseInvoiceEntity { ID = pi.ID, InvoiceDate = pi.PI_Date, Amount = pi.PI_Tot_bef_Tax, Price = pid.PI_Price, Quantity = pid.PI_Qty == null?0:pid.PI_Qty }).ToList <PurchaseInvoiceEntity>(); return(lstCodes); } } catch (Exception ex) { throw ex; } }
public List <PandSQtyAndStockModel> GetPandSList() { List <PandSQtyAndStockModel> lstCodes = new List <PandSQtyAndStockModel>(); using (SDNProductDBEntities objEntities = new SDNProductDBEntities()) { try { lstCodes = (from code in objEntities.ProductsAndServices where (code.IsDeleted == false || code.IsDeleted == null) select new PandSQtyAndStockModel { PSID = code.ID, PSCode = code.PandS_Code, PSName = code.PandS_Name, Category1 = code.PandS_Cat1, Category2 = code.PandS_Cat2, QtyInStock = code.PandS_Qty_in_stock, PSType = code.PandS_Type, IsInActive = code.PandS_Inactive, AvgCostPriceAfterGSTd = code.PandS_Ave_Cost_Price_aft_GST, AvgCostPriceBeforeGSTd = code.PandS_Ave_Cost_Price_bef_GST, StdPriceAfterGSTd = code.PandS_Std_Cost_Price_aft_GST, StdPriceBeforeGSTd = code.PandS_Std_Cost_Price_bef_GST }).OrderBy(e => e.PSName).ToList <PandSQtyAndStockModel>(); return(lstCodes); } catch (Exception ex) { throw ex; } } }
/// <summary> /// This method is used to get category content /// </summary> /// <returns></returns> public List <ContentModel> GetCategoryContent(string catType) { List <ContentModel> lstContents = new List <ContentModel>(); using (SDNProductDBEntities objProdEntities = new SDNProductDBEntities()) { try { lstContents = (from content in objProdEntities.CategoriesContents join cat in objProdEntities.Categories on content.Cat_Id equals cat.ID where cat.Cat_Code == catType && content.IsDeleted == false select new ContentModel { CategoryID = cat.ID, ContentID = content.ID, ContentName = content.Cat_Contents, IsSelected = content.Set_Default }).ToList(); return(lstContents); } catch (Exception ex) { throw ex; } } }
public List <PandSDetailsModel> GetAllPandSNames() { List <PandSDetailsModel> lstCodes = new List <PandSDetailsModel>(); using (SDNProductDBEntities objEntities = new SDNProductDBEntities()) { try { lstCodes = (from code in objEntities.ProductsAndServices where code.IsDeleted == false select new PandSDetailsModel { ID = code.ID, PSCode = code.PandS_Code, PSName = code.PandS_Description, }).ToList <PandSDetailsModel>(); return(lstCodes); } catch (Exception ex) { throw ex; } } }
public void UpdateRefreshData(int psID) { try { using (SDNProductDBEntities objEntities = new SDNProductDBEntities()) { ProductsAndService pands = objEntities.ProductsAndServices.Where(p => p.ID == psID).SingleOrDefault(); if (pands != null) { pands.IsRefresh = true; pands.RefreshDate = DateTime.Now.Date; objEntities.SaveChanges(); } List <ProductsAndService> pandsOther = objEntities.ProductsAndServices.Where(e => e.ID != psID).ToList(); if (pandsOther != null) { foreach (var item in pandsOther) { item.IsRefresh = false; item.RefreshDate = null; objEntities.SaveChanges(); } } } } catch (Exception ex) { throw ex; } }
public bool SaveSearchJson(string jsonSearch, int ScreenId, string ScreenName) { try { using (SDNProductDBEntities entities = new SDNProductDBEntities()) { var result = entities.LastSelectionHistories.Where(x => x.Screen_Id == ScreenId).FirstOrDefault(); if (result != null) { result.Last_Selection = jsonSearch; result.Last_Updated = DateTime.Now; entities.SaveChanges(); return(true); } else { LastSelectionHistory lastSelection = new LastSelectionHistory() { Screen_Id = ScreenId, Screen_Name = ScreenName, Last_Selection = jsonSearch, Last_Updated = DateTime.Now }; entities.LastSelectionHistories.Add(lastSelection); entities.SaveChanges(); return(true); } } } catch { return(false); } }
public List <CountAndAdjustStockListEntity> GetAllStockCount() { List <CountAndAdjustStockListEntity> scList = new List <CountAndAdjustStockListEntity>(); try { using (SDNProductDBEntities entities = new SDNProductDBEntities()) { scList = entities.StockCounts.Select(e => new CountAndAdjustStockListEntity { CountAndAdjustStockNo = e.Stock_count_no, CountAndAdjustStockDateDatetime = e.StockDate, AdjustedAmountd = e.Amount, CreatedDate = e.UpdatedDate }).ToList <CountAndAdjustStockListEntity>(); } scList = scList.OrderBy(e => e.CreatedDate).GroupBy(e => e.CountAndAdjustStockNo).Select(e => e.First()).ToList(); } catch (Exception ex) { throw ex; } return(scList); }
/// <summary> /// This method is used to get all the taxes which are not deleted and inactive /// </summary> /// <returns></returns> public List <TaxModel> GetTax() { List <TaxModel> lstContents = new List <TaxModel>(); using (SDNProductDBEntities objProdEntities = new SDNProductDBEntities()) { try { lstContents = (from tax in objProdEntities.TaxCodesAndRates where tax.IsDeleted == false && tax.Tax_Inactive.Trim() == "N" // && tax.Tax_Default==true select new TaxModel { TaxID = tax.ID, TaxDescription = tax.Tax_Description, TaxCode = tax.Tax_Code, TaxName = tax.Tax_Name, TaxRate = tax.Tax_Rate, IsDefault = tax.Tax_Default, IsInActive = tax.Tax_Inactive }).ToList(); return(lstContents); } catch (Exception ex) { throw ex; } } }
public List <SalesInvoiceEntity> GetSalesInvoiceDetails(int psID) { string pandsID = Convert.ToString(psID); try { List <SalesInvoiceEntity> lstCodes = new List <SalesInvoiceEntity>(); using (SDNProductDBEntities objprodEntities = new SDNProductDBEntities()) { lstCodes = (from pi in objprodEntities.SalesInvoices join pid in objprodEntities.SalesInvoiceDetails on pi.ID equals pid.SI_ID where pid.SI_No == pandsID orderby pi.CreatedDate descending select new SalesInvoiceEntity { ID = pi.ID, //PSCode = pid.PandS_Code, // PSName = pid.PandS_Name, InvoiceDate = pi.SI_Date, Amount = pid.SI_Amount, Price = pid.SI_Price, Quantity = pid.SI_Qty }).ToList <SalesInvoiceEntity>(); return(lstCodes); } } catch (Exception ex) { throw ex; } }
public int SaveCountAndAdjustStock(CountAndAdjustStockForm casForm) { try { using (SDNProductDBEntities entities = new SDNProductDBEntities()) { foreach (var item in casForm.CountAndAdjustStockDetails) { StockCount obj = new StockCount(); obj.Stock_count_no = casForm.CountAndAdjustStock.StockCountNo; obj.StockDate = casForm.CountAndAdjustStock.StockDate; obj.StockType = casForm.CountAndAdjustStock.StockType; //saving details entity obj.PSID = item.PSID; obj.PandS_Code = item.PandSCode; obj.PandS_Name = item.PandSName; obj.SysQty = item.SystemQty; obj.CountQty = item.CountQty; obj.Difference = item.Difference; obj.Average_Cost = Convert.ToDecimal(item.AvgCost); obj.Amount = item.Amount; obj.Adjusted_Amount = item.AdjustedAmount; obj.UpdatedBy = 0; obj.UpdatedDate = DateTime.Now; entities.StockCounts.Add(obj); entities.SaveChanges(); ProductsAndService ps = entities.ProductsAndServices.SingleOrDefault(e => e.ID == item.PSID); if (ps != null) { if (casForm.CountAndAdjustStock.StockType == Convert.ToByte(Stock_Type.StockDamaged)) { ps.PandS_Qty_in_stock = ps.PandS_Qty_in_stock - Convert.ToInt32(Math.Abs(Convert.ToInt32(item.CountQty))); entities.SaveChanges(); } else { ps.PandS_Qty_in_stock = ps.PandS_Qty_in_stock + item.CountQty; entities.SaveChanges(); } } } } } catch (Exception ex) { return(0); throw ex; } return(1); }
public void UpdatePandS(PandSDetailsModel pandsModel) { try { using (SDNProductDBEntities objEntities = new SDNProductDBEntities()) { ProductsAndService pands = objEntities.ProductsAndServices.Where(p => p.ID == pandsModel.ID).SingleOrDefault(); if (pands != null) { pands.PandS_Code = pandsModel.PSCode; pands.PandS_Name = pandsModel.PSName; pands.PandS_Type = pandsModel.PSType; pands.PandS_Cat1 = pandsModel.PSCategory1; pands.PandS_Cat2 = pandsModel.PSCategory2; pands.Tax_Rate = pandsModel.TaxRate; pands.Tax_ID = pandsModel.TaxID; pands.PandS_Description = pandsModel.PSDescription; pands.PandS_Inactive = pandsModel.IsInActive == null?null:pandsModel.IsInActive; pands.PandS_Stock_Picture = pandsModel.ImgSource; //Standard Sell and cost price pands.PandS_Std_Sell_Price_bef_GST = Convert.ToDecimal(pandsModel.StandardSellPriceBeforeGST); pands.PandS_Std_Sell_Price_aft_GST = Convert.ToDecimal(pandsModel.StandardSellPriceAfterGST); pands.PandS_Std_Cost_Price_bef_GST = Convert.ToDecimal(pandsModel.StandardCostpriceBeforeGST); pands.PandS_Std_Cost_Price_aft_GST = Convert.ToDecimal(pandsModel.StandardCostpriceAfterGST); //Average pands.PandS_Ave_Sell_Price_bef_GST = Convert.ToDecimal(pandsModel.AverageSellPriceBeforeGST); pands.PandS_Ave_Sell_Price_aft_GST = Convert.ToDecimal(pandsModel.AverageSellPriceAfterGST); pands.PandS_Ave_Cost_Price_bef_GST = Convert.ToDecimal(pandsModel.AverageCostPriceBeforeGST); pands.PandS_Ave_Cost_Price_aft_GST = Convert.ToDecimal(pandsModel.AverageCostPriceAfterGST); //Last pands.PandS_Last_Sold_Price_bef_GST = Convert.ToDecimal(pandsModel.LastSoldPriceBeforeGST); pands.PandS_Last_Sold_Price_aft_GST = Convert.ToDecimal(pandsModel.LastSoldPriceAfterGST); pands.PandS_Last_Pur_Price_bef_GST = Convert.ToDecimal(pandsModel.LastPurchasePriceBeforeGST); pands.PandS_Last_Pur_Price_aft_GST = Convert.ToDecimal(pandsModel.LastPurchasePriceAfterGST); //Stock pands.PandS_Min_Qty = pandsModel.MinimumQuantity; pands.PandS_Qty_in_stock = pandsModel.QuantityInStock; pands.PandS_Qty_for_SO = pandsModel.ReservedForSalesOrders; pands.PandS_Qty_on_PO = pandsModel.OnPurchaseOrders; pands.PandS_Stock_Value = pandsModel.StockValue; pands.ModifiedBy = pandsModel.LoggedinUserID; pands.ModifiedDate = DateTime.Now; pands.IsRefresh = false; pands.RefreshDate = null; objEntities.SaveChanges(); } } } catch (Exception ex) { throw ex; } }
public List <PandSDetailsModel> GetAllPandSCodes() { List <PandSDetailsModel> lstCodes = new List <PandSDetailsModel>(); using (SDNProductDBEntities objEntities = new SDNProductDBEntities()) { try { lstCodes = (from code in objEntities.ProductsAndServices where (code.IsDeleted == false || code.IsDeleted == null) select new PandSDetailsModel { ID = code.ID, PSCode = code.PandS_Code, PSName = code.PandS_Name, PSCategory1 = code.PandS_Cat1, PSCategory2 = code.PandS_Cat2, TaxID = code.Tax_ID, TaxRate = code.Tax_Rate, PSType = code.PandS_Type, PSDescription = code.PandS_Description, IsInActive = code.PandS_Inactive, StandardSellPriceBeforeGST = code.PandS_Std_Sell_Price_bef_GST.ToString(), StandardSellPriceAfterGST = code.PandS_Std_Sell_Price_aft_GST.ToString(), StandardCostpriceBeforeGST = code.PandS_Std_Cost_Price_bef_GST.ToString(), StandardCostpriceAfterGST = code.PandS_Std_Cost_Price_aft_GST.ToString(), AverageSellPriceBeforeGST = code.PandS_Ave_Sell_Price_bef_GST.ToString(), AverageSellPriceAfterGST = code.PandS_Ave_Sell_Price_aft_GST.ToString(), AverageCostPriceAfterGST = code.PandS_Ave_Cost_Price_aft_GST.ToString(), AverageCostPriceBeforeGST = code.PandS_Ave_Cost_Price_bef_GST.ToString(), LastSoldPriceBeforeGST = code.PandS_Last_Sold_Price_bef_GST.ToString(), LastSoldPriceAfterGST = code.PandS_Last_Sold_Price_aft_GST.ToString(), LastPurchasePriceBeforeGST = code.PandS_Last_Pur_Price_bef_GST.ToString(), LastPurchasePriceAfterGST = code.PandS_Last_Pur_Price_aft_GST.ToString(), MinimumQuantity = code.PandS_Min_Qty, QuantityInStock = code.PandS_Qty_in_stock, ReservedForSalesOrders = code.PandS_Qty_for_SO, OnPurchaseOrders = code.PandS_Qty_on_PO, StockValue = code.PandS_Stock_Value, ImgSource = code.PandS_Stock_Picture, IsRefreshData = code.IsRefresh == null?false:code.IsRefresh, RefreshDate = code.RefreshDate == null?(code.ModifiedDate == null?code.CreatedDate:code.ModifiedDate): code.RefreshDate }).OrderBy(e => e.PSName).ToList <PandSDetailsModel>(); return(lstCodes); } catch (Exception ex) { throw ex; } } }
public CountAndAdjustStockForm GetCountAndAdjustStock(string stockCountNo) { CountAndAdjustStockForm casform = new CountAndAdjustStockForm(); try { using (SDNProductDBEntities entities = new SDNProductDBEntities()) { var pq = (from pqs in entities.StockCounts where pqs.Stock_count_no == stockCountNo select new CountAndAdjustStockEntity { StockCountNo = pqs.Stock_count_no, StockDate = pqs.StockDate, Type = pqs.StockType }).FirstOrDefault(); if (pq != null) { casform.CountAndAdjustStock = pq; } var pqd = (from pqs in entities.StockCounts where pqs.Stock_count_no == stockCountNo select new CountAndAdjustStockDetailsEntity { PSID = pqs.PSID, PandSCode = pqs.PandS_Code, PandSName = pqs.PandS_Name, SystemQty = pqs.SysQty, CountQty = pqs.CountQty, Difference = pqs.Difference, AverageCost = pqs.Average_Cost, Amount = pqs.Amount }).ToList <CountAndAdjustStockDetailsEntity>(); if (pqd != null) { casform.CountAndAdjustStockDetails = pqd; } return(casform); } } catch (Exception ex) { throw ex; } }
public List <TopPandSEntity> GetPandSList(string JsonData) { List <TopPandSEntity> topPandS = new List <TopPandSEntity>(); try { using (SDNProductDBEntities entities = new SDNProductDBEntities()) { if (JsonData != null && JsonData != "[]") { var objResponse1 = JsonConvert.DeserializeObject <List <SearchEntity> >(JsonData); topPandS = entities.Database.SqlQuery <TopPandSEntity>("USP_GetTopPandS @year, @Quarter,@Month,@IncGST,@ShowAll,@PandS,@SDate,@EDate", new Object[] { new SqlParameter("year", Convert.ToInt64(objResponse1[0].FieldValue)), new SqlParameter("Quarter", Convert.ToInt64(objResponse1[1].FieldValue)), new SqlParameter("Month", Convert.ToInt64(objResponse1[2].FieldValue)), new SqlParameter("IncGST", objResponse1[3].FieldValue), new SqlParameter("ShowAll", objResponse1[4].FieldValue), new SqlParameter("PandS", Convert.ToInt64(objResponse1[5].FieldValue)), new SqlParameter("SDate", objResponse1[6].FieldValue), new SqlParameter("EDate", objResponse1[7].FieldValue), } ).ToList(); } else { topPandS = entities.Database.SqlQuery <TopPandSEntity>("USP_GetTopPandS @year,@Quarter,@Month,@IncGST,@ShowAll,@PandS,@SDate,@EDate", new SqlParameter("year", Convert.ToInt64(0)), new SqlParameter("Quarter", Convert.ToInt64(0)), new SqlParameter("Month", Convert.ToInt64(0)), new SqlParameter("IncGST", true), new SqlParameter("ShowAll", true), new SqlParameter("PandS", Convert.ToInt64(0)), new SqlParameter("SDate", ""), new SqlParameter("EDate", "") ).ToList(); } } } catch (Exception ex) { throw ex; } return(topPandS); }
public string GetLatestStockCountNo() { string sNo = string.Empty; try { using (SDNProductDBEntities entities = new SDNProductDBEntities()) { var pq = (from pqs in entities.StockCounts orderby pqs.UpdatedDate descending select new { pqs.ID, pqs.Stock_count_no, pqs.UpdatedDate } ).ToList(); if (pq.Count > 0) { sNo = pq.Take(1).SingleOrDefault().Stock_count_no; if (sNo != null) { string[] str = sNo.Split('-'); if (str != null) { sNo = Convert.ToString(Convert.ToInt64(str[1]) + 1); } } } else { sNo = Convert.ToString(1); } } return(sNo); } catch (Exception ex) { throw ex; } }
public void DeletePandS(PandSDetailsModel pandsModel) { try { using (SDNProductDBEntities objEntities = new SDNProductDBEntities()) { ProductsAndService pands = objEntities.ProductsAndServices.Where(p => p.ID == pandsModel.ID).SingleOrDefault(); if (pands != null) { pands.IsDeleted = true; pands.ModifiedBy = pandsModel.LoggedinUserID; pands.ModifiedDate = DateTime.Now; objEntities.SaveChanges(); } } } catch (Exception ex) { throw ex; } }
public string GetLastSelectionData(int ScreenId) { try { using (SDNProductDBEntities entities = new SDNProductDBEntities()) { var result = entities.LastSelectionHistories.Where(x => x.Screen_Id == ScreenId).FirstOrDefault(); if (result != null) { return(result.Last_Selection); } else { return(null); } } } catch (Exception ex) { throw ex; } }
public string GetDateFormat() { try { using (SDNProductDBEntities entities = new SDNProductDBEntities()) { var DateFormatResult = entities.Options.FirstOrDefault(); string DateFormat = null; if (DateFormatResult != null) { return(DateFormat = DateFormatResult.Date_Format); } else { return(DateFormat = null); } } } catch (Exception ex) { throw ex; } }
public List <PandSListModel> GetPandSComboList() { List <PandSListModel> lstCodes = new List <PandSListModel>(); using (SDNProductDBEntities objEntities = new SDNProductDBEntities()) { try { lstCodes = (from code in objEntities.ProductsAndServices where (code.IsDeleted == false || code.IsDeleted == null) select new PandSListModel { ID = code.ID, PSCode = code.PandS_Code, PSName = code.PandS_Name, TaxID = code.Tax_ID, TaxRate = code.Tax_Rate, PSType = code.PandS_Type, IsInActive = code.PandS_Inactive, SellPriceExcludingTax = code.PandS_Std_Sell_Price_bef_GST, SellPriceIncludingTax = code.PandS_Std_Sell_Price_aft_GST, CostPriceExcludingTax = code.PandS_Std_Cost_Price_bef_GST, CostPriceIncludingTax = code.PandS_Std_Cost_Price_aft_GST, SellPriceExcludingTaxBackup = code.PandS_Std_Sell_Price_bef_GST, SellPriceIncludingTaxBackup = code.PandS_Std_Sell_Price_aft_GST, CostPriceExcludingTaxBackup = code.PandS_Std_Cost_Price_bef_GST, CostPriceIncludingTaxBackup = code.PandS_Std_Cost_Price_aft_GST }).OrderBy(e => e.PSName).ToList <PandSListModel>(); return(lstCodes); } catch (Exception ex) { throw ex; } } }
public List <CountAndAdjustStockListEntity> GetAllStockCountJson(string JsonData) { List <CountAndAdjustStockListEntity> scList = new List <CountAndAdjustStockListEntity>(); List <CountAndAdjustStockListEntity> quotationListReturn = new List <CountAndAdjustStockListEntity>(); try { using (SDNProductDBEntities entities = new SDNProductDBEntities()) { scList = entities.StockCounts.Select(e => new CountAndAdjustStockListEntity { CountAndAdjustStockNo = e.Stock_count_no, CountAndAdjustStockDateDatetime = e.StockDate, AdjustedAmountd = e.Amount, CreatedDate = e.UpdatedDate }).ToList <CountAndAdjustStockListEntity>(); } scList = scList.OrderBy(e => e.CreatedDate).GroupBy(e => e.CountAndAdjustStockNo).Select(e => e.First()).ToList(); if (JsonData != null && JsonData != "[]") { DateTime startDate = new DateTime(); var objResponse1 = JsonConvert.DeserializeObject <List <SearchEntity> >(JsonData); foreach (var item in objResponse1) { switch (item.FieldName) { case "Year": var year = Convert.ToInt32(item.FieldValue); scList = scList.Where(x => x.CountAndAdjustStockDateDatetime.Value.Year == year).ToList(); break; case "Quarter": switch (item.FieldValue) { case "1": scList = scList.Where(x => x.CountAndAdjustStockDateDatetime.Value.Month == 1 || x.CountAndAdjustStockDateDatetime.Value.Month == 2 || x.CountAndAdjustStockDateDatetime.Value.Month == 3).ToList(); break; case "2": scList = scList.Where(x => x.CountAndAdjustStockDateDatetime.Value.Month == 4 || x.CountAndAdjustStockDateDatetime.Value.Month == 5 || x.CountAndAdjustStockDateDatetime.Value.Month == 6).ToList(); break; case "3": scList = scList.Where(x => x.CountAndAdjustStockDateDatetime.Value.Month == 7 || x.CountAndAdjustStockDateDatetime.Value.Month == 8 || x.CountAndAdjustStockDateDatetime.Value.Month == 9).ToList(); break; case "4": scList = scList.Where(x => x.CountAndAdjustStockDateDatetime.Value.Month == 10 || x.CountAndAdjustStockDateDatetime.Value.Month == 11 || x.CountAndAdjustStockDateDatetime.Value.Month == 12).ToList(); break; } break; case "Month": var month = Convert.ToInt32(item.FieldValue); scList = scList.Where(x => x.CountAndAdjustStockDateDatetime.Value.Month == month).ToList(); break; case "StartDate": //startDate = Convert.ToDateTime(item.FieldValue); startDate = DateTime.ParseExact(item.FieldValue, "MMM/dd/yyyy", CultureInfo.InvariantCulture); //quotationList = quotationList.Where(x => x.QuotationDateDateTime ).ToList(); break; case "EndDate": //DateTime endDate = Convert.ToDateTime(item.FieldValue); DateTime endDate = DateTime.ParseExact(item.FieldValue, "MMM/dd/yyyy", CultureInfo.InvariantCulture); scList = scList.Where(x => x.CountAndAdjustStockDateDatetime > startDate && x.CountAndAdjustStockDateDatetime < endDate).ToList(); break; } } quotationListReturn = scList; } else { quotationListReturn = scList; } } catch (Exception ex) { throw ex; } return(quotationListReturn); }
public int UpdateCountAndAdjustStock(CountAndAdjustStockForm casForm) { try { using (SDNProductDBEntities entities = new SDNProductDBEntities()) { var data = entities.StockCounts.Where(e => e.Stock_count_no == casForm.CountAndAdjustStock.StockCountNo).ToList(); if (data != null) { foreach (var d in data) { ProductsAndService psOld = entities.ProductsAndServices.SingleOrDefault(e => e.ID == d.PSID); if (psOld != null) { if (d.StockType == Convert.ToByte(Stock_Type.StockDamaged)) { psOld.PandS_Qty_in_stock = psOld.PandS_Qty_in_stock + Convert.ToInt32(Math.Abs(Convert.ToInt32(d.CountQty))); entities.SaveChanges(); } else { psOld.PandS_Qty_in_stock = psOld.PandS_Qty_in_stock - d.CountQty; entities.SaveChanges(); } } var item = casForm.CountAndAdjustStockDetails.SingleOrDefault(e => e.PSID == d.PSID); if (item != null) { //saving details entity d.PandS_Code = item.PandSCode; d.PandS_Name = item.PandSName; d.SysQty = item.SystemQty; d.CountQty = item.CountQty; d.Difference = item.Difference; d.Average_Cost = Convert.ToDecimal(item.AvgCost); d.Amount = item.Amount; d.Adjusted_Amount = item.AdjustedAmount; d.UpdatedBy = 0; d.UpdatedDate = DateTime.Now; entities.SaveChanges(); } ProductsAndService ps = entities.ProductsAndServices.SingleOrDefault(e => e.ID == d.PSID); if (ps != null) { if (casForm.CountAndAdjustStock.StockType == Convert.ToByte(Stock_Type.StockDamaged)) { ps.PandS_Qty_in_stock = ps.PandS_Qty_in_stock - Convert.ToInt32(Math.Abs(Convert.ToInt32(d.CountQty))); entities.SaveChanges(); } else { ps.PandS_Qty_in_stock = ps.PandS_Qty_in_stock + d.CountQty; entities.SaveChanges(); } } } } } } catch (Exception ex) { return(0); throw ex; } return(1); }
public OptionsEntity GetOptionsDetails() { OptionsEntity result = new OptionsEntity(); using (SDNProductDBEntities entites = new SDNProductDBEntities()) { //IEnumerable<Account> accountsource = entites.Accounts.ToList(); //result.AccountDetails = accountsource; Option source = entites.Options.FirstOrDefault(); if (source != null) { result.ID = source.ID; result.AllowEditDiscount = source.Allow_Edit_Discount; if (source.Allow_Edit_Discount == true) { result.AllowEditDiscountTrue = true; result.AllowEditDiscountFalse = false; } else { result.AllowEditDiscountTrue = false; result.AllowEditDiscountFalse = true; } result.AllowEditPSNameDesc = source.Allow_Edit_PS_Name_Desc; if (source.Allow_Edit_PS_Name_Desc == true) { result.AllowEditPSNameDescTrue = true; result.AllowEditPSNameDescFalse = false; } else { result.AllowEditPSNameDescTrue = false; result.AllowEditPSNameDescFalse = true; } result.AllowEditPSPrice = source.Allow_Edit_PS_Price; if (source.Allow_Edit_PS_Price == true) { result.AllowEditPSPriceTrue = true; result.AllowEditPSPriceFalse = false; } else { result.AllowEditPSPriceTrue = false; result.AllowEditPSPriceFalse = true; } result.AllowToCreateSaleInv = source.Allow_to_Create_Sales_Inv; if (source.Allow_to_Create_Sales_Inv == true) { result.AllowToCreateSaleInvTrue = true; result.AllowToCreateSaleInvFalse = false; } else { result.AllowToCreateSaleInvTrue = false; result.AllowToCreateSaleInvFalse = true; } result.CurrencyCode = source.Currency_Code; result.CusDetailAllowChgLimit = source.Cus_Detail_Allow_Chg_Limit; if (source.Cus_Detail_Allow_Chg_Limit == true) { result.CusDetailAllowChgLimitTrue = true; result.CusDetailAllowChgLimitFalse = false; } else { result.CusDetailAllowChgLimitTrue = false; result.CusDetailAllowChgLimitFalse = true; } result.DateFormat = source.Date_Format; result.DecimalPlaces = Convert.ToByte(source.Decimal_Places); result.DefCashBankAcc = source.Def_Cash_Bank_Acc; result.AccountID = source.Def_Cash_Bank_Acc; result.HideDiscColumn = source.Hide_Discount_Column; if (source.Hide_Discount_Column == true) { result.HideDiscColumnTrue = true; result.HideDiscColumnFalse = false; } else { result.HideDiscColumnTrue = false; result.HideDiscColumnFalse = true; } result.NametoPrintSalesInv = source.Name_to_Print_Sales_Invoice; result.CurrencyName = source.Number_Format; result.PrintPSName = source.Print_PS_Name; if (source.Print_PS_Name == true) { result.PrintPSNameTrue = true; result.PrintPSNameFalse = false; } else { result.PrintPSNameTrue = false; result.PrintPSNameFalse = true; } result.PrintPSNameDesc = source.Print_PS_Name_Desc; if (source.Print_PS_Name_Desc == true) { result.PrintPSNameDescTrue = true; result.PrintPSNameDescFalse = false; } else { result.PrintPSNameDescTrue = false; result.PrintPSNameDescFalse = true; } result.PSDetailAllowChgAct = source.PS_Detail_Allow_Chg_Act; if (source.PS_Detail_Allow_Chg_Act == true) { result.PSDetailAllowChgActTrue = true; result.PSDetailAllowChgActFalse = false; } else { result.PSDetailAllowChgActTrue = false; result.PSDetailAllowChgActFalse = true; } result.PSQtyJumNextLine = source.PS_Qty_Jump_Next_Line; if (source.PS_Qty_Jump_Next_Line == true) { result.PSQtyJumNextLineTrue = true; result.PSQtyJumNextLineFalse = false; } else { result.PSQtyJumNextLineTrue = false; result.PSQtyJumNextLineFalse = true; } result.ShowAccountBal = source.Show_Account_Balance; if (source.Show_Account_Balance == true) { result.ShowAccountBalTrue = true; result.ShowAccountBalFalse = false; } else { result.ShowAccountBalTrue = false; result.ShowAccountBalFalse = true; } result.ShowAmountIncGST = source.Show_Amount_Inc_GST; if (source.Show_Amount_Inc_GST == true) { result.ShowAmountIncGSTTrue = true; result.ShowAmountIncGSTFalse = false; } else { result.ShowAmountIncGSTTrue = false; result.ShowAmountIncGSTFalse = true; } result.ShowPSName = source.Show_PS_Name; if (source.Show_PS_Name == true) { result.ShowPSNameTrue = true; result.ShowPSNameFalse = false; } else { result.ShowPSNameTrue = false; result.ShowPSNameFalse = true; } result.ShowPSNameDesc = source.Show_PS_Name_Desc; if (source.Show_PS_Name_Desc == true) { result.ShowPSNameDescTrue = true; result.ShowPSNameDescFalse = false; } else { result.ShowPSNameDescTrue = false; result.ShowPSNameDescFalse = true; } result.PrintDelSalesInv = source.Print_Del_Sales_Inv; if (source.Print_Del_Sales_Inv == true) { result.PrintDelSalesInvTrue = true; result.PrintDelSalesInvFalse = false; } else { result.PrintDelSalesInvTrue = false; result.PrintDelSalesInvFalse = true; } result.StartingSalesInvNo = source.Starting_Sales_Inv_No; } return(result); } }