File manager - Edit - G:/PleskVhosts/indiaminerals.in/tlt.INFOFIXDEVELOPERS.COM/admin/Directsale.aspx.cs
Back
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.Services; using System.Web.Script.Services; using Newtonsoft.Json; using Business; using WebApp.LIBS; using Newtonsoft.Json.Linq; using System.Transactions; using System.Text.RegularExpressions; namespace WebApp.admin { public partial class Directsale : BasePageClass { protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { Common.BindControl(SupplierId, Global.Context.Customers.AsEnumerable().ToList(), "EnglishName", "CustomerId", "Select"); Common.BindControl(HamalId, Global.Context.Hamals.AsEnumerable().ToList(), "HamalName", "HamalId", "Select"); Common.BindControl(LocationId, Global.Context.Locations.AsEnumerable().Select(p => new { p.LocationId, p.LocationName }).ToList(), "LocationName", "LocationId", "Select"); if (Request.QueryString["SaleId"].ConvertInt() > 0) { int Id = Request.QueryString["SaleId"].ConvertInt(); var obj = Global.Context.Sales.SingleOrDefault(p => p.SaleId == Id); SupplierId.SelectedValue = obj.CustomerId.Value.ToString(); InvoiceNo.Text = obj.InvoiceNo.ToString(); Dates.Text = obj.Date.Value.ToString("dd/MM/yyyy"); Hamalis.Text = obj.Hamali.ToString(); TotalAmountTotal.Text = obj.TotalQuantity.Value.ToString(); try { HamalId.SelectedValue = obj.HamalId.Value.ToString(); } catch { } try { LocationId.SelectedValue = obj.LocationId.Value.ToString(); } catch { } try { var Datax = Global.Context.Locations.SingleOrDefault(p => p.LocationId == obj.LocationId); LocationRate.Value = Datax.Rate.Value.ToString("0.00"); FormulaRate.Value = Common.Convertstring(Datax.CalcFormula); } catch { } } else { int compId = SiteSession.CompnayId; int SessionId = SiteSession.SessionId; InvoiceNo.Text = (Global.Context.InvNoes.Where(p => p.CompnayId == compId && p.SesssionId == SessionId).Count() + 1).ToString(); Dates.Text = Common.DateTimeNow().ToString("dd/MM/yyyy"); } InvoiceNo.Enabled = false; } } [WebMethod] [ScriptMethod(ResponseFormat = ResponseFormat.Json)] public static string UpdateBilty(string SaleId) { int ChallanIds = SaleId.ConvertInt(); int ComId = SiteSession.CompnayId; var obj = Global.Context.Items.AsEnumerable().Where(p => p.CompnayId == ComId).ToList(); var objBrand = Global.Context.Brands.AsEnumerable().Where(p => p.CompnayId == ComId).ToList(); var Weight = Global.Context.Weights.AsEnumerable().Where(p => p.CompnayId == ComId).ToList(); return JsonConvert.SerializeObject(Global.Context.SaleItems.AsEnumerable().Where(p => p.SaleId == ChallanIds).ToList().Select(p => new { p.SaleItemId, p.ItemId, p.Quantity, Item = StationListUpdate(obj, p.ItemId.Value), Brand = BrandListUpdate(objBrand, p.ItemId.Value, p.BrandId.Value), Weight = WeightListUpdate(Weight, p.ItemId.Value, p.BrandId.Value, p.WeightId.Value), p.Weightkg, stockqty = StockDataUpdateTime(p.ItemId.Value, p.BrandId.Value, p.WeightId.Value, p.Weightkg, p.Quantity.Value), Kg = Common.Convertstring(p.Weight.Kg) }).ToList()); } [WebMethod] [ScriptMethod(ResponseFormat = ResponseFormat.Json)] public static string StationListUpdate(List<Item> obj, int Id) { string returnstr = "<option value='0'>Select </option>"; obj.ForEach(x => { returnstr = returnstr + " " + ("<option value='" + x.ItemId + "' " + (Id == x.ItemId ? "selected" : "") + ">" + x.ItemName + "</option>"); }); return returnstr; } [WebMethod] [ScriptMethod(ResponseFormat = ResponseFormat.Json)] public static string LocationRates(string LocationId) { try { int LocationIdid = LocationId.ConvertInt(); var obj = Global.Context.Locations.SingleOrDefault(parameters => parameters.LocationId == LocationIdid); return (obj.Rate.HasValue ? obj.Rate.Value.ToString() : "0") + "<>" + Common.Convertstring(obj.CalcFormula); } catch { return "0<>"; } } [WebMethod] [ScriptMethod(ResponseFormat = ResponseFormat.Json)] public static string Hamalirate(string Id) { try { int IDS = Id.ConvertInt(); return Global.Context.Locations.SingleOrDefault(p => p.LocationId == IDS).Rate.Value.ToString(); } catch { return "0.00"; } } [WebMethod] [ScriptMethod(ResponseFormat = ResponseFormat.Json)] public static string ListForCombo() { return Global.Context.DropdownOptionItem(SiteSession.CompnayId).FirstOrDefault(); } [WebMethod] [ScriptMethod(ResponseFormat = ResponseFormat.Json)] public static string ListBrand(string ItemId) { int ChallanIds = ItemId.ConvertInt(); int ComId = SiteSession.CompnayId; var obj = Global.Context.Brands.AsEnumerable().Where(p => p.ItemId == ChallanIds).ToList(); return JsonConvert.SerializeObject(obj.ToList().Select(p => new { p.BrandId, p.BrandName, }).ToList()); } [WebMethod] [ScriptMethod(ResponseFormat = ResponseFormat.Json)] public static string ListWeight(string BrandId, string ItemId) { int ChallanIds = ItemId.ConvertInt(); int BrandIds = BrandId.ConvertInt(); var obj = Global.Context.Weights.AsEnumerable().Where(p => p.ItemId == ChallanIds && p.BrandId == BrandIds).ToList(); return JsonConvert.SerializeObject(obj.ToList().Select(p => new { p.WeightId, p.WeightName, }).ToList()); } [WebMethod] [ScriptMethod(ResponseFormat = ResponseFormat.Json)] public static string deleteitem(string SaleItemId) { try { int Id = SaleItemId.ConvertInt(); var obj = Global.Context.SaleItems.SingleOrDefault(p => p.SaleItemId == Id); obj.Delete(); return "1<>Suc"; } catch (Exception ex) { return "0<>" + ex.Message; } } [WebMethod] [ScriptMethod(ResponseFormat = ResponseFormat.Json)] public static string StockData(string Itemid, string BrandId, string WeightId, string WeightKG) { string KG = "0"; try { int WeightIdId = WeightId.ConvertInt(); var KGFormula = Global.Context.Weights.SingleOrDefault(p => p.WeightId == WeightIdId); KG = KGFormula.Kg; } catch { } try { return Global.Context.ExecuteStoreQuery<KeyDataHolder>("select dbo.[GetOpeningStockForCheck](" + Itemid + "," + BrandId + "," + WeightId + "," + SiteSession.CompnayId + ") as KeyData").FirstOrDefault().KeyData.ToString() + "<>" + KG; } catch (Exception ex) { return "0<>" + KG; } } public static decimal StockDataUpdateTime(int Itemid, int BrandId, int WeightId, string WeightKG, decimal qty) { try { return Global.Context.ExecuteStoreQuery<KeyDataHolder>("select dbo.[GetOpeningStockForCheck](" + Itemid + "," + BrandId + "," + WeightId + "," + SiteSession.CompnayId + ",'" + (WeightKG).Replace(" ", "").ToUpper() + "') as KeyData").FirstOrDefault().KeyData + qty; } catch (Exception ex) { return qty; } } [WebMethod] [ScriptMethod(ResponseFormat = ResponseFormat.Json)] public static string BrandListUpdate(List<Brand> obj, int ItemId, int BrandId) { string returnstr = "<option value='0'>Select </option>"; obj.Where(p => p.ItemId == ItemId).ToList().ForEach(x => { returnstr = returnstr + " " + ("<option value='" + x.BrandId + "' " + (BrandId == x.BrandId ? "selected" : "") + ">" + x.BrandName + "</option>"); }); return returnstr; } [WebMethod] [ScriptMethod(ResponseFormat = ResponseFormat.Json)] public static string WeightListUpdate(List<Weight> obj, int ItemId, int BrandId, int WeightId) { string returnstr = "<option value='0'>Select </option>"; obj.Where(p => p.ItemId == ItemId && p.BrandId == BrandId).ToList().ForEach(x => { returnstr = returnstr + " " + ("<option value='" + x.WeightId + "' " + (WeightId == x.WeightId ? "selected" : "") + ">" + x.WeightName + "</option>"); }); return returnstr; } [System.Web.Services.WebMethod] public static string SaveChallandatasale(string SaleId, string VehicleNo, string SupplierId, string Dates, string InvoiceNo, string HamalId, string Hamali, string LocationId, string TotalQunatity,string TotalAmount,string BiltyList) { try { var itemList = JsonConvert.DeserializeObject<List<SaleItem>>(BiltyList); itemList.ForEach(C => { C.WeightId = C.WeightId.Split('[')[0].ToString(); }); HttpContext.Current.Session["SaleId"] = SaleId; HttpContext.Current.Session["VehicleNo"] = VehicleNo; HttpContext.Current.Session["SupplierId"] = SupplierId; HttpContext.Current.Session["Dates"] = Dates; HttpContext.Current.Session["InvoiceNo"] = InvoiceNo; HttpContext.Current.Session["HamalId"] = HamalId; HttpContext.Current.Session["Hamali"] = Hamali; HttpContext.Current.Session["LocationId"] = LocationId; HttpContext.Current.Session["TotalQuantity"] = TotalQunatity; HttpContext.Current.Session["BiltyList"] = itemList; HttpContext.Current.Session["TotalAmountTotal"] = TotalAmount; HttpContext.Current.Session["CustomerName"] = SupplierId; return "Data has been successfully saved to session."; } catch (Exception ex) { var message = ex.InnerException?.Message ?? ex.Message; if (message.Contains("UNIQUE KEY")) { message = "Record already exists. Please enter another."; } return $"Error<>{message}"; } } } }
| ver. 1.4 |
Github
|
.
| PHP 7.3.33 | Generation time: 0.08 |
proxy
|
phpinfo
|
Settings