protected void gridMain_InsertCommand(object source, GridCommandEventArgs e) { var editableItem = ((GridEditableItem)e.Item); using (var dbContext = new OTERTConnStr()) { var currPricelist = new PTSGRPricelist(); Hashtable values = new Hashtable(); editableItem.ExtractValues(values); try { currPricelist.Name = (string)values["Name"]; currPricelist.InstallationCost = decimal.Parse((string)values["InstallationCost"]); currPricelist.ChargesPerMonth = decimal.Parse((string)values["ChargesPerMonth"]); currPricelist.ChargesPerDay = decimal.Parse((string)values["ChargesPerDay"]); currPricelist.MSNPerMonth = decimal.Parse((string)values["MSNPerMonth"]); currPricelist.MSNPerDay = decimal.Parse((string)values["MSNPerDay"]); if (currPricelist.MSNPerMonth > 0 || currPricelist.MSNPerDay > 0) { currPricelist.SupportsMSN = true; } else { currPricelist.SupportsMSN = false; } currPricelist.HasRouter = (bool)values["HasRouter"]; currPricelist.IsChargePerMonth = (bool)values["IsChargePerMonth"]; dbContext.PTSGRPricelist.Add(currPricelist); dbContext.SaveChanges(); } catch (Exception) { ShowErrorMessage(-1); } } }
public List <PlaceB> GetPlaces(int recSkip, int recTake, string recFilter, GridSortExpressionCollection gridSortExxpressions) { using (var dbContext = new OTERTConnStr()) { try { dbContext.Configuration.ProxyCreationEnabled = false; IQueryable <PlaceB> datatmp = (from us in dbContext.Places select new PlaceB { ID = us.ID, CountryID = us.CountryID, NameGR = us.NameGR, NameEN = us.NameEN, Country = new CountryDTO { ID = us.Countries.ID, NameGR = us.Countries.NameGR, NameEN = us.Countries.NameEN } }); if (!string.IsNullOrEmpty(recFilter)) { datatmp = datatmp.Where(recFilter); } if (gridSortExxpressions.Count > 0) { datatmp = datatmp.OrderBy(gridSortExxpressions[0].FieldName + " " + gridSortExxpressions[0].SortOrder); } else { datatmp = datatmp.OrderByDescending(o => o.ID); } List <PlaceB> data = datatmp.Skip(recSkip).Take(recTake).ToList(); return(data); } catch (Exception) { return(null); } } }
protected void gridMain_UpdateCommand(object source, GridCommandEventArgs e) { var editableItem = ((GridEditableItem)e.Item); var ID = (int)editableItem.GetDataKeyValue("ID"); using (var dbContext = new OTERTConnStr()) { var place = dbContext.Places.Where(n => n.ID == ID).FirstOrDefault(); if (place != null) { editableItem.UpdateValues(place); if (Session["CountryID"] != null) { newID = int.Parse(Session["CountryID"].ToString()); } if (newID > 0) { place.CountryID = newID; newID = -1; Session.Remove("CountryID"); } try { dbContext.SaveChanges(); } catch (Exception) { ShowErrorMessage(-1); } } } }
protected void gridMain_InsertCommand(object source, GridCommandEventArgs e) { var editableItem = ((GridEditableItem)e.Item); using (var dbContext = new OTERTConnStr()) { var place = new Places(); Hashtable values = new Hashtable(); editableItem.ExtractValues(values); if (Session["CountryID"] != null) { newID = int.Parse(Session["CountryID"].ToString()); } if (newID > 0) { try { place.CountryID = newID; place.NameGR = (string)values["NameGR"]; place.NameEN = (string)values["NameEN"]; dbContext.Places.Add(place); dbContext.SaveChanges(); } catch (Exception) { ShowErrorMessage(-1); } finally { newID = -1; Session.Remove("CountryID"); } } else { ShowErrorMessage(-1); } } }
public List <JobB> GetDistinctJobsForInvoice(int invoiceID) { using (var dbContext = new OTERTConnStr()) { try { dbContext.Configuration.ProxyCreationEnabled = false; List <TasksLineB> tmp = GetTaskLinesForInvoice(invoiceID); List <int> DistinctJobID = tmp.Select(x => x.JobID).Distinct().ToList(); tmp.Clear(); List <JobB> DistinctJobs = new List <JobB>(); JobsController jCont = new JobsController(); foreach (int jid in DistinctJobID) { JobB curjob = jCont.GetJob(jid); if (curjob != null) { DistinctJobs.Add(curjob); } } DistinctJobID.Clear(); List <JobB> SortedList = DistinctJobs.OrderBy(o => o.Name).ToList(); DistinctJobs.Clear(); return(SortedList); } catch (Exception) { return(null); } } }
public List <UserB> GetUsers() { using (var dbContext = new OTERTConnStr()) { try { dbContext.Configuration.ProxyCreationEnabled = false; List <UserB> data = (from us in dbContext.Users select new UserB { ID = us.ID, UserGroupID = us.UserGroupID, NameGR = us.NameGR, NameEN = us.NameEN, Telephone = us.Telephone, FAX = us.FAX, Email = us.Email, UserName = us.UserName, Password = us.Password, UserGroup = new UserGroupDTO { ID = us.UserGroups.ID, Name = us.UserGroups.Name } }).OrderBy(o => o.NameGR).ToList(); return(data); } catch (Exception) { return(null); } } }
public JobB GetJob(int JobID) { using (var dbContext = new OTERTConnStr()) { try { dbContext.Configuration.ProxyCreationEnabled = false; JobB data = (from us in dbContext.Jobs select new JobB { ID = us.ID, JobsMainID = us.JobsMainID, JobsMain = new JobMainDTO { ID = us.JobsMain.ID, PageID = us.JobsMain.PageID, Name = us.JobsMain.Name }, JobTypesID = us.JobTypesID, JobType = new JobTypeDTO { ID = us.JobTypes.ID, Name = us.JobTypes.Name }, Name = us.Name, MinimumTime = us.MinimumTime, InvoiceCode = us.InvoiceCode, SalesID = us.SalesID, Sale = us.SalesID == null ? null : new SaleDTO { ID = us.Sales.ID, Name = us.Sales.Name, Type = us.Sales.Type } }).Where(o => o.ID == JobID).FirstOrDefault(); return(data); } catch (Exception) { return(null); } } }
public List <DistanceB> GetDistances(int recSkip, int recTake, string recFilter, GridSortExpressionCollection gridSortExxpressions) { using (var dbContext = new OTERTConnStr()) { try { dbContext.Configuration.ProxyCreationEnabled = false; IQueryable <DistanceB> datatmp = (from us in dbContext.Distances select new DistanceB { ID = us.ID, JobsMainID = us.JobsMainID, JobsMain = new JobMainDTO { ID = us.JobsMain.ID, PageID = us.JobsMain.PageID, Name = us.JobsMain.Name }, Description = us.Position1 + " - " + us.Position2 + " (" + us.KM.ToString() + " km)", Position1 = us.Position1, Position2 = us.Position2, KM = us.KM }); if (!string.IsNullOrEmpty(recFilter)) { datatmp = datatmp.Where(recFilter); } if (gridSortExxpressions.Count > 0) { datatmp = datatmp.OrderBy(gridSortExxpressions[0].FieldName + " " + gridSortExxpressions[0].SortOrder); } else { datatmp = datatmp.OrderByDescending(o => o.ID); } List <DistanceB> data = datatmp.Skip(recSkip).Take(recTake).ToList(); return(data); } catch (Exception) { return(null); } } }
public object GetUsers(string strValue) { strValue = strValue.Substring(1, strValue.Length - 1); strValue = strValue.Remove(strValue.Length - 1); //strValue = strValue.Replace(@"\"", "\""); //DataManager value = WSUtils.Deserialize<DataManager>(strValue); using (var dbContext = new OTERTConnStr()) { try { dbContext.Configuration.ProxyCreationEnabled = false; var data = (from us in dbContext.Users select new UserB { ID = us.ID, UserGroup = new UserGroupDTO { ID = us.UserGroups.ID, Name = us.UserGroups.Name }, NameGR = us.NameGR, NameEN = us.NameEN, Telephone = us.Telephone, FAX = us.FAX, Email = us.Email, UserName = us.UserName, Password = us.Password }).ToList(); var count = data.Count; //data = data.Skip(value.Skip).Take(value.Take).ToList(); data = data.ToList(); object responseObj = new { result = data, count = count }; return(new JavaScriptSerializer().Serialize(responseObj)); } catch (Exception) { return(null); } } }
public List <JobB> GetJobs() { using (var dbContext = new OTERTConnStr()) { try { dbContext.Configuration.ProxyCreationEnabled = false; List <JobB> data = (from us in dbContext.Jobs select new JobB { ID = us.ID, JobsMainID = us.JobsMainID, JobsMain = new JobMainDTO { ID = us.JobsMain.ID, PageID = us.JobsMain.PageID, Name = us.JobsMain.Name }, JobTypesID = us.JobTypesID, JobType = new JobTypeDTO { ID = us.JobTypes.ID, Name = us.JobTypes.Name }, Name = us.Name, MinimumTime = us.MinimumTime, InvoiceCode = us.InvoiceCode, SalesID = us.SalesID, Sale = us.SalesID == null ? null : new SaleDTO { ID = us.Sales.ID, Name = us.Sales.Name, Type = us.Sales.Type } }).OrderBy(o => o.Name).ToList(); return(data); } catch (Exception) { return(null); } } }
protected void gridMain_UpdateCommand(object source, GridCommandEventArgs e) { var editableItem = ((GridEditableItem)e.Item); var ID = (int)editableItem.GetDataKeyValue("ID"); using (var dbContext = new OTERTConnStr()) { var curDistance = dbContext.Distances.Where(n => n.ID == ID).FirstOrDefault(); if (curDistance != null) { editableItem.UpdateValues(curDistance); if (Session["JobsMainID"] != null) { JobsMainID = int.Parse(Session["JobsMainID"].ToString()); } if (JobsMainID > 0 && Session["Position1"] != null && Session["Position1"] != null) { curDistance.Position1 = Session["Position1"].ToString(); curDistance.Position2 = Session["Position2"].ToString(); curDistance.JobsMainID = JobsMainID; JobsMainID = -1; Session.Remove("JobsMainID"); Session.Remove("Position1"); Session.Remove("Position2"); } try { dbContext.SaveChanges(); } catch (Exception) { ShowErrorMessage(-1); } } } }
public object GetPlaces(string strValue) { strValue = strValue.Substring(1, strValue.Length - 1); strValue = strValue.Remove(strValue.Length - 1); //strValue = strValue.Replace(@"\"", "\""); //DataManager value = WSUtils.Deserialize<DataManager>(strValue); using (var dbContext = new OTERTConnStr()) { try { dbContext.Configuration.ProxyCreationEnabled = false; var data = (from pl in dbContext.Places.Take(200) select new PlaceB { ID = pl.ID, Country = new CountryDTO { ID = pl.Countries.ID, NameGR = pl.Countries.NameGR, NameEN = pl.Countries.NameEN, }, NameGR = pl.NameGR, NameEN = pl.NameEN }).ToList(); var count = data.Count; //data = data.Skip(value.Skip).Take(value.Take).ToList(); data = data.ToList(); object responseObj = new { result = data, count = count }; return(new JavaScriptSerializer().Serialize(responseObj)); } catch (Exception) { return(null); } } }
public List <EventB> GetEvents(int recSkip, int recTake, string recFilter, GridSortExpressionCollection gridSortExxpressions) { using (var dbContext = new OTERTConnStr()) { try { dbContext.Configuration.ProxyCreationEnabled = false; List <EventB> data = (from us in dbContext.Events select new EventB { ID = us.ID, PlaceID = us.PlaceID, NameGR = us.NameGR, NameEN = us.NameEN, Place = new PlaceDTO { ID = us.Places.ID, NameGR = us.Places.NameGR, NameEN = us.Places.NameEN, Country = new CountryDTO { ID = us.Places.Countries.ID, NameGR = us.Places.Countries.NameGR, NameEN = us.Places.Countries.NameEN }, CountryID = us.Places.CountryID } }).OrderBy(o => o.ID).Skip(recSkip).Take(recTake).ToList(); return(data); } catch (Exception) { return(null); } } }
public List <EventB> GetGreekEvents() { using (var dbContext = new OTERTConnStr()) { try { dbContext.Configuration.ProxyCreationEnabled = false; List <EventB> data = (from us in dbContext.Events select new EventB { ID = us.ID, PlaceID = us.PlaceID, NameGR = us.NameGR, NameEN = us.NameEN, Place = new PlaceDTO { ID = us.Places.ID, NameGR = us.Places.NameGR, NameEN = us.Places.NameEN, Country = new CountryDTO { ID = us.Places.Countries.ID, NameGR = us.Places.Countries.NameGR, NameEN = us.Places.Countries.NameEN }, CountryID = us.Places.CountryID } }).Where(k => k.Place.CountryID == 1).OrderBy(o => o.NameGR).ToList(); return(data); } catch (Exception) { return(null); } } }
public int CountDistances(string recFilter) { using (var dbContext = new OTERTConnStr()) { try { int count = 0; dbContext.Configuration.ProxyCreationEnabled = false; if (!string.IsNullOrEmpty(recFilter)) { //count = dbContext.Distances.Where(recFilter).Count(); IQueryable <DistanceB> datatmp = (from us in dbContext.Distances select new DistanceB { ID = us.ID, JobsMainID = us.JobsMainID, JobsMain = new JobMainDTO { ID = us.JobsMain.ID, PageID = us.JobsMain.PageID, Name = us.JobsMain.Name }, Description = us.Position1 + " - " + us.Position2 + " (" + us.KM.ToString() + " km)", Position1 = us.Position1, Position2 = us.Position2, KM = us.KM }); count = datatmp.Where(recFilter).Count(); } else { count = dbContext.Distances.Count(); } return(count); } catch (Exception) { return(-1); } } }
public List <JobB> GetJobs(int recSkip, int recTake, string recFilter) { using (var dbContext = new OTERTConnStr()) { try { dbContext.Configuration.ProxyCreationEnabled = false; IQueryable <JobB> test = (from us in dbContext.Jobs select new JobB { ID = us.ID, JobsMainID = us.JobsMainID, JobsMain = new JobMainDTO { ID = us.JobsMain.ID, PageID = us.JobsMain.PageID, Name = us.JobsMain.Name }, JobTypesID = us.JobTypesID, JobType = new JobTypeDTO { ID = us.JobTypes.ID, Name = us.JobTypes.Name }, Name = us.Name, MinimumTime = us.MinimumTime, InvoiceCode = us.InvoiceCode, SalesID = us.SalesID, Sale = us.SalesID == null ? null : new SaleDTO { ID = us.Sales.ID, Name = us.Sales.Name, Type = us.Sales.Type } }); if (!string.IsNullOrEmpty(recFilter)) { test = test.Where(recFilter); } test = test.OrderBy(o => o.Name); List <JobB> data = test.Skip(recSkip).Take(recTake).ToList(); return(data); } catch (Exception) { return(null); } } }
public List <PTSGRPricelistB> GetPTSGRPricelists(int recSkip, int recTake, string recFilter) { using (var dbContext = new OTERTConnStr()) { try { dbContext.Configuration.ProxyCreationEnabled = false; IQueryable <PTSGRPricelistB> datatmp = (from us in dbContext.PTSGRPricelist select new PTSGRPricelistB { ID = us.ID, Name = us.Name, InstallationCost = us.InstallationCost, ChargesPerMonth = us.ChargesPerMonth, ChargesPerDay = us.ChargesPerDay, MSNPerMonth = us.MSNPerMonth == null ? 0 : us.MSNPerMonth, MSNPerDay = us.MSNPerDay == null ? 0 : us.MSNPerDay, HasRouter = us.HasRouter, SupportsMSN = us.SupportsMSN, IsChargePerMonth = us.IsChargePerMonth }); if (!string.IsNullOrEmpty(recFilter)) { datatmp = datatmp.Where(recFilter); } List <PTSGRPricelistB> data = datatmp.OrderBy(o => o.ID).Skip(recSkip).Take(recTake).ToList(); return(data); } catch (Exception) { return(null); } } }
protected void gridMain_UpdateCommand(object source, GridCommandEventArgs e) { var editableItem = ((GridEditableItem)e.Item); var ID = (int)editableItem.GetDataKeyValue("ID"); using (var dbContext = new OTERTConnStr()) { var docRep = dbContext.DocumentReplacemets.Where(n => n.ID == ID).FirstOrDefault(); if (docRep != null) { editableItem.UpdateValues(docRep); if (Session["textFromSession"] != null) { textFromSession = Session["textFromSession"].ToString().Trim(); } if (!string.IsNullOrEmpty(textFromSession)) { docRep.Text = textFromSession; textFromSession = ""; Session.Remove("textFromSession"); } try { dbContext.SaveChanges(); } catch (Exception) { ShowErrorMessage(); } } } }
public int CountCountryPricelists() { using (var dbContext = new OTERTConnStr()) { try { return(dbContext.CountryPricelist.Count()); } catch (Exception) { return(-1); } } }
public int CountDocumentReplacemets(string usw) { using (var dbContext = new OTERTConnStr()) { try { return(dbContext.DocumentReplacemets.Where(o => o.UniqueName.StartsWith(usw)).Count()); } catch (Exception) { return(-1); } } }
public int CountJobCancelPrices(int jobsID) { using (var dbContext = new OTERTConnStr()) { try { return(dbContext.JobCancelPrices.Where(k => k.JobsID == jobsID).Count()); } catch (Exception) { return(-1); } } }
public int CountOrders(int orderType) { using (var dbContext = new OTERTConnStr()) { try { return(dbContext.Orders.Where(o => o.OrderTypeID == orderType).Count()); } catch (Exception) { return(-1); } } }
public int CountCustomerTypes() { using (var dbContext = new OTERTConnStr()) { try { return(dbContext.CustomerTypes.Count()); } catch (Exception) { return(-1); } } }
public int CountFilesByCustomerID(int customerID) { using (var dbContext = new OTERTConnStr()) { try { return(dbContext.Files.Where(k => k.CustomerID == customerID).Count()); } catch (Exception) { return(-1); } } }
public int CountFiles(int taskID) { using (var dbContext = new OTERTConnStr()) { try { return(dbContext.Files.Where(k => k.TaskID == taskID).Count()); } catch (Exception) { return(-1); } } }
public int CountRequestedPositions() { using (var dbContext = new OTERTConnStr()) { try { return(dbContext.RequestedPositions.Count()); } catch (Exception) { return(-1); } } }
public int CountSatelites() { using (var dbContext = new OTERTConnStr()) { try { return(dbContext.Satelites.Count()); } catch (Exception) { return(-1); } } }
public int CountJobsMain() { using (var dbContext = new OTERTConnStr()) { try { return(dbContext.JobsMain.Count()); } catch (Exception) { return(-1); } } }
public int CountSalesFormulas(int salesID) { using (var dbContext = new OTERTConnStr()) { try { return(dbContext.SalesFormulas.Where(k => k.SalesID == salesID).Count()); } catch (Exception) { return(-1); } } }
public CountryPricelistB GetCountryPricelist(int CustomerID, int LineTypeID) { using (var dbContext = new OTERTConnStr()) { try { dbContext.Configuration.ProxyCreationEnabled = false; CountryPricelistB data = (from us in dbContext.CountryPricelist select new CountryPricelistB { ID = us.ID, CustomerID = us.CustomerID, Customer = new CustomerDTO { ID = us.Customers.ID, CountryID = us.Customers.CountryID, NameGR = us.Customers.NameGR, NameEN = us.Customers.NameEN, NamedInvoiceGR = us.Customers.NamedInvoiceGR, NamedInvoiceEN = us.Customers.NamedInvoiceEN, ZIPCode = us.Customers.ZIPCode, CityGR = us.Customers.CityGR, CityEN = us.Customers.CityEN, ChargeTelephone = us.Customers.ChargeTelephone, Telephone1 = us.Customers.Telephone1, Telephone2 = us.Customers.Telephone2, FAX1 = us.Customers.FAX1, FAX2 = us.Customers.FAX2, Address1GR = us.Customers.Address1GR, Address1EN = us.Customers.Address1EN, Address2GR = us.Customers.Address2GR, Address2EN = us.Customers.Address2EN, ContactPersonGR = us.Customers.ContactPersonGR, ContactPersonEN = us.Customers.ContactPersonEN, CustomerTypeID = us.Customers.CustomerTypeID, LanguageID = us.Customers.LanguageID, Email = us.Customers.Email, URL = us.Customers.URL, AFM = us.Customers.AFM, DOY = us.Customers.DOY, SAPCode = us.Customers.SAPCode, UserID = us.Customers.UserID, Comments = us.Customers.Comments, IsProvider = us.Customers.IsProvider, IsOTE = us.Customers.IsOTE }, LineTypeID = us.LineTypeID, LineType = new LineTypeDTO { ID = us.LineTypes.ID, Name = us.LineTypes.Name }, InstallationCost = us.InstallationCost, MonthlyCharges = us.MonthlyCharges, Internet = us.Internet, MSN = us.MSN, PaymentIsForWholeMonth = us.PaymentIsForWholeMonth }).Where(o => o.CustomerID == CustomerID && o.LineTypeID == LineTypeID).FirstOrDefault(); return(data); } catch (Exception) { return(null); } } }