public Factory GetUserById(string userName, string password) { _context = new ISEEEntities(); return _context.Factories.Where(u => u.UserName == userName && u.Password == password).SingleOrDefault(); // return _context.Factory.Where(u => u.UserName == userName && u.Password == password).SingleOrDefault(); //return _context.User.Where(u => u. == Id).SingleOrDefault(); }
public bool SaveClassificationRequestCustomerByDate(int customerID, string requestDate, int level2, string request, string treatment, string treatmentDate) { try { using (ISEEEntities context = new ISEEEntities()) { CustomerRequest customerRequest = new CustomerRequest(); customerRequest.CreateDate = Convert.ToDateTime(requestDate); if (!string.IsNullOrEmpty(treatmentDate)) { customerRequest.TreatmentDate = Convert.ToDateTime(treatmentDate); } customerRequest.Treatment = treatment; customerRequest.Request = request; customerRequest.RequestSysIdLevel2 = level2; customerRequest.Status = 0; customerRequest.CustomerId = customerID; context.CustomerRequests.Add(customerRequest); context.SaveChanges(); return(true); } } catch (Exception) { return(false); } }
//Save Classificion request public bool UpdateClassificationRequestCustomerByDate(int customerID, string requestDate, int level2, string request, string treatment, string treatmentDate, int requestSysIdLevel1, int requestSysIdLevel2, int sysId) { try { using (ISEEEntities context = new ISEEEntities()) { CustomerRequest customerRequest = context.CustomerRequests.Where(x => x.SysId == sysId).FirstOrDefault(); if (!string.IsNullOrEmpty(treatmentDate)) { customerRequest.TreatmentDate = Convert.ToDateTime(treatmentDate); } customerRequest.Treatment = treatment; customerRequest.Request = request; customerRequest.RequestSysIdLevel2 = level2; customerRequest.Status = 0; customerRequest.RequsetToFactoryLevel2.RequestSysIdLevel1 = requestSysIdLevel1; context.CustomerRequests.Add(customerRequest); context.SaveChanges(); return(true); } } catch (Exception) { return(false); } }
public Factory GetUserById(string userName, string password) { _context = new ISEEEntities(); return(_context.Factories.Where(u => u.UserName == userName && u.Password == password).SingleOrDefault()); // return _context.Factory.Where(u => u.UserName == userName && u.Password == password).SingleOrDefault(); //return _context.User.Where(u => u. == Id).SingleOrDefault(); }
public JsonResult GetCustomerByIdOnLoad(string customerID) { if (customerID != "") { using (ISEEEntities context = new ISEEEntities()) { var result = _facory.GetCustomersByCustomerID(customerID).Select(x => new { CustomerId = x.CustomerId, CustomerNumber = x.CustomerNumber, FirstName = x.FirstName, LastName = x.LastName, AreaPhone1 = x.AreaPhone1 ?? "!@#$", Phone1 = x.Phone1 ?? "!@#$", Lat = x.Building.Lat, BuildingCode = x.BuildingCode, BuildingNumber = x.Building.Number ?? "!@#$", Long = x.Building.Long, ZipCode = x.Building.ZipCode, StreetName = x.Building.Street.StreetDesc ?? "!@#$", StreetId = x.Building.Street.StateCode, CityId = x.Building.Street.City.CityCode, CityName = x.Building.Street.City.CityDesc ?? "!@#$", StateName = x.Building.Street.City.State.StateDesc ?? "!@#$", StateId = x.Building.Street.City.State.StateCode }).ToList();; return(new JsonResult { Data = result, JsonRequestBehavior = JsonRequestBehavior.AllowGet }); } } return(new JsonResult { Data = null, JsonRequestBehavior = JsonRequestBehavior.AllowGet }); }
public string UpdateEmployee(int employeeId, string number, string mail, string firstName, string lastName, string phone1, string phone11, string phone2, string phone22, string Start, int manufacture, int phoneType, string end, string hourlyData) { var mainData = Newtonsoft.Json.JsonConvert.DeserializeObject <List <ISEEDataModel.Repository.employeeHours> >(hourlyData); int days = 0; try { foreach (var item in mainData) { days = Int32.Parse(item.Day); using (ISEEEntities db = new ISEEEntities()) { ISEEDataModel.Repository.EmployeeDiaryTemplate factoryDairyTemplet = db.EmployeeDiaryTemplates.Where(x => x.EmployeeId == employeeId && x.DayStatus == days).FirstOrDefault(); if (factoryDairyTemplet != null) { factoryDairyTemplet.Start1 = Common.GetTimeSpan(item.Start1); factoryDairyTemplet.Stop1 = Common.GetTimeSpan(item.End1); factoryDairyTemplet.Start2 = Common.GetTimeSpan(item.Start2); factoryDairyTemplet.Stop2 = Common.GetTimeSpan(item.End2); db.SaveChanges(); } } } using (ISEEEntities db = new ISEEEntities()) { Employee employee = db.Employees.Where(x => x.EmployeeId == employeeId).FirstOrDefault(); if (employee != null) { employee.EmployeeNum = number; employee.Mail = mail.Trim(); employee.FirstName = firstName.Trim(); employee.LastName = lastName.Trim(); employee.MainAreaPhone = phone1.Trim(); employee.MainPhone = phone11.Trim(); employee.SecondAreaPhone = phone2.Trim(); employee.SecondPhone = phone22.Trim(); employee.PhoneManufactory = manufacture; employee.PhoneType = phoneType; if (!string.IsNullOrEmpty(Start)) { employee.StartDay = Common.ConvertDateTime(Start); } if (!string.IsNullOrEmpty(end)) { employee.EndDay = Common.ConvertDateTime(end); } else { employee.EndDay = null; } db.SaveChanges(); } } } catch (Exception) { return("false"); } return("true"); }
public bool SaveEmployeeHours(string objhours, int employeeID) { int factoryId = SessionManagement.FactoryID; var mainData = Newtonsoft.Json.JsonConvert.DeserializeObject <List <ISEEDataModel.Repository.employeeHours> >(objhours); if (employeeID > 0) { using (ISEEEntities context = new ISEEEntities()) { foreach (var item in mainData) { EmployeeDiaryTemplate factoryDairyTemplet = new EmployeeDiaryTemplate(); factoryDairyTemplet.DayStatus = (int)((Days)Enum.Parse(typeof(Days), item.Day)); factoryDairyTemplet.EmployeeId = employeeID; factoryDairyTemplet.Start1 = Common.Common.GetTimeSpan(item.Start1); factoryDairyTemplet.Stop1 = Common.Common.GetTimeSpan(item.End1); factoryDairyTemplet.Start2 = Common.Common.GetTimeSpan(item.Start2); factoryDairyTemplet.Stop2 = Common.Common.GetTimeSpan(item.End2); factoryDairyTemplet.OrderDay = (int)((Days)Enum.Parse(typeof(Days), item.Day)); context.EmployeeDiaryTemplates.Add(factoryDairyTemplet); context.SaveChanges(); } return(true); } } return(false); }
public string SenderSMSMexico(int empID, string _strMsg, string _phone, double CurrentGmt) { // string strXML1 = "Appname=Port2SMS&prgname=HTTP_SimpleSMS1&AccountID=1037&UserID=10130&UserPass=1037&Phone=0506447976&Text=Test"; string strXML = "Appname=Port2SMS&prgname=HTTP_SimpleSMS1&AccountID=1037&UserID=10130&UserPass=1037&Phone=" + _phone + "&Text=" + _strMsg; string result = PostDataToURL("http://ign-sms.com/Scripts/mgrqispi.dll?", strXML); ////one time get result empty(check )!!!!!! int Status; if (result.Contains("OK")) { Status = 1; } else { Status = -1; } //add and save row to DB EmployeeSmsSend emp_sms = new EmployeeSmsSend(); emp_sms.EmployeeId = empID; emp_sms.SmsCreatDate = DateTime.Now.AddHours(CurrentGmt); emp_sms.SmsMsg = _strMsg; emp_sms.SmsCount = 1; emp_sms.SmsStatus = Convert.ToInt32(Status); using (ISEEEntities context = new ISEEEntities()) { context.EmployeeSmsSends.Add(emp_sms); context.SaveChanges(); } return(result); }
//Bind Main Classsification DDL public JsonResult BindClassificationDdl() { using (ISEEEntities dataContext = new ISEEEntities()) { var factoryLevel1list = dataContext.RequsetToFactoryLevel1.Where(d => d.Factory == SessionManagement.FactoryID).OrderBy(c => c.RequsetOrder).Select(x => new { x.RequestSysIdLevel1, x.RequestDescCodeLevel1, x.RequsetOrder, x.StatusCode, x.Factory }).ToList(); return(Json(factoryLevel1list, JsonRequestBehavior.AllowGet)); } }
//Bind Second Classsification DDL public JsonResult BindSecondClassificationDdl(int id) { using (ISEEEntities dataContext = new ISEEEntities()) { var factoryLevel1list = dataContext.RequsetToFactoryLevel2.Where(d => d.RequestSysIdLevel1 == id).OrderBy(c => c.RequsetOrder).Select(x => new { x.RequestSysIdLevel2, x.RequestDescCodeLevel2 }).ToList(); return(Json(factoryLevel1list, JsonRequestBehavior.AllowGet)); } }
public JsonResult GetCountries() { using (ISEEEntities context = new ISEEEntities()) { var ret = context.LanguageLists.Select(d => d.LanguageNickname).Distinct().ToList(); var selectedImageUrl = string.Format("/images/img/{0}.png", SessionManagement.Language.Trim().ToLower()); var result = ret.Select(c => new { LanguageNickname = c.Trim(), ImageUrl = string.Format("/images/img/{0}.png", c.Trim().ToLower()) }).ToList(); return(Json(new { CountryList = result, SelectedCountry = SessionManagement.Language, SelectedCountryImageUrl = selectedImageUrl }, JsonRequestBehavior.AllowGet)); } }
public JsonResult GetPhoneTypes(int id) { using (ISEEEntities context = new ISEEEntities()) { var phoneTypes = context.PhoneTypes.Where(x => x.PhoneManufacturId == id).Select(c => new { PhoneTypeCode = c.PhoneTypeCode, PhoneTypeDesc = c.PhoneTypeDesc }).ToList(); return(new JsonResult { Data = phoneTypes, JsonRequestBehavior = JsonRequestBehavior.AllowGet }); } }
//Customer Tab public JsonResult GetEmployeeByEmployeeID(int EmployeeID) { using (ISEEEntities context = new ISEEEntities()) { var result = context.Employees.Where(e => e.EmployeeId == EmployeeID).Select(q => new { employeeID = q.EmployeeId, FirstName = q.FirstName, LastName = q.LastName, MainAreaPhone = q.MainAreaPhone, MainPhone = q.MainPhone }).FirstOrDefault(); return(new JsonResult { Data = result, JsonRequestBehavior = JsonRequestBehavior.AllowGet }); } }
public JsonResult GetSecondary(Int32 sysIdLevel1, int?ContactStatus) { using (ISEEEntities dataContext = new ISEEEntities()) { var factoryLevel2list = dataContext.RequsetToFactoryLevel2.Where(d => d.RequestSysIdLevel1 == sysIdLevel1).Select(x => new { x.RequestDescCodeLevel2, x.RequsetOrder, x.RequestSysIdLevel1, x.RequestSysIdLevel2, x.StatusCode }).ToList(); //if (ContactStatus.HasValue) //{ // factoryLevel2list = factoryLevel2list.Where(c => c.StatusCode == ContactStatus).ToList(); //} return(Json(factoryLevel2list, JsonRequestBehavior.AllowGet)); } }
public JsonResult GetEmployeeHours() { int factoryId = SessionManagement.FactoryID; using (ISEEEntities context = new ISEEEntities()) { var EmpHours = context.FactoryDairyTemplets.Where(s => s.Factory == factoryId).ToList().Select(e => new { Day = ((Days)Enum.ToObject(typeof(Days), e.DayStatus)).ToString(), Start1 = e.Start1 != null ? Convert.ToDateTime(e.Start1.Value.ToString()).ToString("hh:mm tt") : null, End1 = e.Stop1 != null ? Convert.ToDateTime(e.Stop1.Value.ToString()).ToString("hh:mm tt") : null, Start2 = e.Start2 != null ? Convert.ToDateTime(e.Start2.Value.ToString()).ToString("hh:mm tt") : null, End2 = e.Stop2 != null ? Convert.ToDateTime(e.Stop2.Value.ToString()).ToString("hh:mm tt") : null, DayStatus = e.DayStatus }).ToList(); object[] EmpHoursData = new object[7]; for (int i = 0; i < EmpHours.Count; i++) { if (EmpHours[i].DayStatus == 1) { EmpHoursData[i] = new { Day = SessionManagement.Sunday, Start1 = EmpHours[i].Start1, End1 = EmpHours[i].End1, Start2 = EmpHours[i].Start2, End2 = EmpHours[i].End2, DayStatus = EmpHours[i].DayStatus } } ; if (EmpHours[i].DayStatus == 2) { EmpHoursData[i] = new { Day = SessionManagement.Monday, Start1 = EmpHours[i].Start1, End1 = EmpHours[i].End1, Start2 = EmpHours[i].Start2, End2 = EmpHours[i].End2, DayStatus = EmpHours[i].DayStatus } } ; if (EmpHours[i].DayStatus == 3) { EmpHoursData[i] = new { Day = SessionManagement.Tuesday, Start1 = EmpHours[i].Start1, End1 = EmpHours[i].End1, Start2 = EmpHours[i].Start2, End2 = EmpHours[i].End2, DayStatus = EmpHours[i].DayStatus } } ; if (EmpHours[i].DayStatus == 4) { EmpHoursData[i] = new { Day = SessionManagement.Wednesday, Start1 = EmpHours[i].Start1, End1 = EmpHours[i].End1, Start2 = EmpHours[i].Start2, End2 = EmpHours[i].End2, DayStatus = EmpHours[i].DayStatus } } ; if (EmpHours[i].DayStatus == 5) { EmpHoursData[i] = new { Day = SessionManagement.Thursday, Start1 = EmpHours[i].Start1, End1 = EmpHours[i].End1, Start2 = EmpHours[i].Start2, End2 = EmpHours[i].End2, DayStatus = EmpHours[i].DayStatus } } ; if (EmpHours[i].DayStatus == 6) { EmpHoursData[i] = new { Day = SessionManagement.Friday, Start1 = EmpHours[i].Start1, End1 = EmpHours[i].End1, Start2 = EmpHours[i].Start2, End2 = EmpHours[i].End2, DayStatus = EmpHours[i].DayStatus } } ; if (EmpHours[i].DayStatus == 7) { EmpHoursData[i] = new { Day = SessionManagement.Saturday, Start1 = EmpHours[i].Start1, End1 = EmpHours[i].End1, Start2 = EmpHours[i].Start2, End2 = EmpHours[i].End2, DayStatus = EmpHours[i].DayStatus } } ; //EmpHours[i].Day = SessionManagement.Sunday; } return(new JsonResult { Data = EmpHoursData, JsonRequestBehavior = JsonRequestBehavior.AllowGet }); } }
// Country tab start public JsonResult GetAllCountrys() { using (ISEEEntities context = new ISEEEntities()) { var StateDec = _facory.GetAllcountries().ToList() .Select(x => new { CountryCode = x.CountryCode.ToString().Trim(), CountryDesc = (x.CountryDesc ?? string.Empty).ToString().Trim(), CurrentGmt = x.CurrentGmt, CountryDescEN = (x.CountryDescEn ?? string.Empty).ToString().Trim() }) .Distinct() .ToList(); return(new JsonResult { Data = StateDec, JsonRequestBehavior = JsonRequestBehavior.AllowGet }); } }
// Bind Visiting Data public JsonResult GetEmployeesToCustomerFilter(int customerID, string dtFrom, string dtTo) { using (ISEEEntities context = new ISEEEntities()) { DateTime from = Convert.ToDateTime(dtFrom); DateTime to = Convert.ToDateTime(dtTo); var gpsEmployeeCustomer = context.GpsEmployeeCustomers.Include("Employee").Where( x => x.CustomerId == customerID && x.VisiteDate >= from && x.VisiteDate <= to).OrderByDescending(x => x.VisiteDate).ToList().Select(x => new { EmployeeNum = x.Employee.EmployeeNum, CreateDate = x.VisiteDate.ToShortDateString(), Time = x.VisitTime.ToString(), FirstName = x.Employee.FirstName, LastName = x.Employee.LastName, EmployeeId = x.EmployeeId, InsertStatus = x.InsertStatus }).ToList(); return(Json(gpsEmployeeCustomer, JsonRequestBehavior.AllowGet)); //.Select(x => new { x.CreateDate, x.CustomerId, x.Employee.FirstName, x.Employee.LastName, x.InsertStatus, x.Employee.EmployeeId, x.SysId, x.VisitTime, x.VisiteDate }) } }
public JsonResult GetAllStatesByCountry() { using (ISEEEntities context = new ISEEEntities()) { var CountryID = SessionManagement.Country; var StateDec = _facory.GetAllStates(CountryID).ToList() .Select(x => new { StateCode = x.StateCode.ToString().Trim(), StateDesc = (x.StateDesc ?? string.Empty).ToString().Trim() }) .Distinct() .ToList(); return(new JsonResult { Data = StateDec, JsonRequestBehavior = JsonRequestBehavior.AllowGet }); } }
//Bind Request Data public JsonResult GetRequestCustomerByDate(int customerID, int fromyear, string from, string to, int level1, int level2) { var fromdate = Convert.ToDateTime(from); var todate = Convert.ToDateTime(to).AddDays(1).AddMilliseconds(-1); //var customerID = this.ObjectContext.Customer.FirstOrDefault(x => x.CustomerKey == CustomerGuidID).CustomerId; using (ISEEEntities context = new ISEEEntities()) { var customerRequest1 = context.CustomerRequests.Include("RequsetToFactoryLevel2").Include("RequsetToFactoryLevel2.RequsetToFactoryLevel1").Where(x => x.CustomerId == customerID && x.RequsetToFactoryLevel2.RequestSysIdLevel1 == (level1 == -1 ? x.RequsetToFactoryLevel2.RequestSysIdLevel1 : level1) && x.RequestSysIdLevel2 == (level2 == -1 ? x.RequestSysIdLevel2 : level2) && (x.CreateDate >= fromdate && x.CreateDate < todate)).ToList().Select(x => new { RequestDescCodeLevel1 = x.RequsetToFactoryLevel2.RequsetToFactoryLevel1.RequestDescCodeLevel1, RequestDescCodeLevel2 = x.RequsetToFactoryLevel2.RequestDescCodeLevel2, CreateDate = x.CreateDate.Date.ToString("dd/MM/yyyy"), Treatment = x.Treatment, TreatmentDate = x.TreatmentDate.ToString(), Request = x.Request, RequestSysIdLevel1 = x.RequsetToFactoryLevel2.RequestSysIdLevel1, RequestSysIdLevel2 = x.RequsetToFactoryLevel2.RequestSysIdLevel2, customerRequestId = x.SysId }).ToList(); return(Json(customerRequest1, JsonRequestBehavior.AllowGet)); } }
public JsonResult getAll(string id) { using (ISEEEntities dataContext = new ISEEEntities()) { if (string.IsNullOrEmpty(id)) { var factoryLevel1list = dataContext.RequsetToFactoryLevel1.Where(d => d.Factory == SessionManagement.FactoryID).OrderBy(c => c.RequsetOrder).Select(x => new { x.RequestSysIdLevel1, x.RequestDescCodeLevel1, x.RequsetOrder, x.StatusCode, x.Factory }).ToList(); return(Json(factoryLevel1list, JsonRequestBehavior.AllowGet)); } else { var factoryLevel1list = dataContext.RequsetToFactoryLevel1.ToList().Where(d => d.Factory == SessionManagement.FactoryID && d.StatusCode == Common.Common.GetInteger(id)).OrderBy(c => c.RequsetOrder).Select(x => new { x.RequestSysIdLevel1, x.RequestDescCodeLevel1, x.RequsetOrder, x.StatusCode, x.Factory }).ToList(); return(Json(factoryLevel1list, JsonRequestBehavior.AllowGet)); } } }
public ActionResult SaveCustomerForm(CustomerDataModel objCustomerData) { string errorMessage = string.Empty; try { int FactoryId = SessionManagement.FactoryID; var CustomerData = objCustomerData; using (ISEEEntities context = new ISEEEntities()) { Customer customer = new Customer(); customer.CreateDate = DateTime.Now; customer.BuildingCode = objCustomerData.BuldingCode; customer.CustomerNumber = objCustomerData.CustomerNumber; customer.Factory = FactoryId; customer.FirstName = objCustomerData.CompanyName; customer.LastName = objCustomerData.ContactName; customer.Floor = objCustomerData.Floor; customer.Apartment = objCustomerData.Apartment; customer.AreaPhone1 = objCustomerData.PhoneArea1; customer.Phone1 = objCustomerData.Phone1; customer.AreaPhone2 = objCustomerData.PhoneArea2; customer.Phone2 = objCustomerData.Phone2; customer.AreaFax = objCustomerData.AreaFax; customer.Fax = objCustomerData.Fax; customer.Mail = objCustomerData.Mail; customer.VisitInterval = objCustomerData.VisitInterval; customer.NextVisit = objCustomerData.NextVisit; customer.VisitTime = objCustomerData.VisitTime; context.Customers.Add(customer); context.SaveChanges(); var customerDetails = new { CustomerID = customer.CustomerId, LastName = customer.LastName, FirstName = customer.FirstName, AreaPhone1 = customer.AreaPhone1, Phone1 = customer.Phone1 }; return(new JsonResult { Data = new { Message = "Success", CustomerDetails = customerDetails }, JsonRequestBehavior = JsonRequestBehavior.AllowGet }); } } catch (Exception ex) { errorMessage = ex.InnerException.Message; } return(new JsonResult { Data = new { Message = "Error", ErrorDetails = errorMessage }, JsonRequestBehavior = JsonRequestBehavior.AllowGet }); }
public string SendSMSClickatell(int empID, string _strMsg, string _phone, string _PhoneAreaCode, double CurrentGmt) { string result = "1"; if (_strMsg.Length < 70) // is limited to 70 characters per message(Clickatell) for unicode { // string phone = _PhoneAreaCode + _phone; //972545500378 string phone = _PhoneAreaCode + "505774499"; WebClient client = new WebClient(); // Add a user agent header in case the requested URI contains a query. client.Headers.Add("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; .NET CLR 1.0.3705;)"); client.QueryString.Add("user", "Dshabi"); client.QueryString.Add("password", "shabi101827"); client.QueryString.Add("api_id", "3349639"); client.QueryString.Add("to", phone); client.QueryString.Add("from", "regionSEE"); client.QueryString.Add("text", ToUnicode(_strMsg)); client.QueryString.Add("unicode", "1"); string baseurl = "http://api.clickatell.com/http/sendmsg"; Stream data = client.OpenRead(baseurl); StreamReader reader = new StreamReader(data); string s = reader.ReadToEnd(); data.Close(); reader.Close(); } else { result = "-1"; } //add and save row to DB EmployeeSmsSend emp_sms = new EmployeeSmsSend(); emp_sms.EmployeeId = empID; emp_sms.SmsCreatDate = DateTime.Now.AddHours(CurrentGmt); emp_sms.SmsMsg = _strMsg; emp_sms.SmsCount = 1; emp_sms.SmsStatus = Convert.ToInt32(result); using (ISEEEntities context = new ISEEEntities()) { context.EmployeeSmsSends.Add(emp_sms); context.SaveChanges(); } return(result); }
public JsonResult GetCurrentLogedUserCountery() { int FactoryId = SessionManagement.FactoryID; if (FactoryId > 0) { using (ISEEEntities context = new ISEEEntities()) { var CountryDetail = context.FactoryParms.Select(c => new { FactoryId = c.FactoryId, CountryID = c.Country, Lat = c.Lat, Long = c.Long, Zoom = c.Zoom, MapProvider = c.MapProvider }).Where(x => x.FactoryId == FactoryId).ToList(); return(new JsonResult { Data = CountryDetail, JsonRequestBehavior = JsonRequestBehavior.AllowGet }); } } return(new JsonResult { Data = null, JsonRequestBehavior = JsonRequestBehavior.AllowGet }); }
public string UpdateCustomer(int customerID, string cNumber, string cCompanyName, string cContactName, string cFloor, string cApartment, string cMail, string cPhoneOne, string cPhone11, string cPhoneTwo, string cPhone22, string cFax, string cFax1, string cRemarks1, string cRemarks2, int cbuildingCode, string cbuildingNumber, string cZipCode, int cvisitInterval, string cEndDate, string cNextVisit, int cvisitTime, string cMobile, string cMobile1) { try { using (ISEEEntities context = new ISEEEntities()) { Customer customer = context.Customers.Where(x => x.CustomerId == customerID).FirstOrDefault(); customer.BuildingCode = cbuildingCode; customer.CustomerNumber = Common.Common.GetNullableValues(cNumber.Trim()); customer.LastName = Common.Common.GetNullableValues(cCompanyName.Trim()); customer.FirstName = Common.Common.GetNullableValues(cContactName.Trim()); customer.Floor = Common.Common.GetNullableValues(cFloor.Trim()); customer.Apartment = Common.Common.GetNullableValues(cApartment.Trim()); customer.AreaPhone1 = Common.Common.GetNullableValues(cPhoneOne.Trim()); customer.Phone1 = Common.Common.GetNullableValues(cPhone11.Trim()); customer.AreaPhone2 = Common.Common.GetNullableValues(cPhoneTwo.Trim()); customer.Phone2 = Common.Common.GetNullableValues(cPhone22.Trim()); customer.AreaFax = Common.Common.GetNullableValues(cFax.Trim()); customer.Fax = Common.Common.GetNullableValues(cFax1.Trim()); customer.Mail = Common.Common.GetNullableValues(cMail.Trim()); customer.CustomerRemark1 = Common.Common.GetNullableValues(cRemarks1.Trim()); customer.CustomerRemark2 = Common.Common.GetNullableValues(cRemarks2.Trim()); customer.EndDate = Common.Common.ConvertDateTime(cEndDate); customer.NextVisit = Common.Common.ConvertDateTime(cNextVisit); customer.VisitTime = cvisitTime; customer.VisitInterval = cvisitInterval; customer.Celolar = Common.Common.GetNullableValues(cMobile1); customer.AreaCelolar = Common.Common.GetNullableValues(cMobile); context.SaveChanges(); } } catch (Exception) { return("false"); } return("true"); }
public JsonResult SaveCompany(int countryId, int currentGmt, int customerLinkDistanceThreshold, string factoryDesc , int factoryId, float lat, float lang, int mapProvider, string password, string phoneAreaCode, int radiusSearch, int smsProvider, bool splitTime, int stopEmployeeTime , string userName, int zoom ) { try { using (ISEEEntities context = new ISEEEntities()) { Factory factory = new Factory(); if (factoryId <= -1) { } else { factory = _facory.GetAllFactoryDataId(factoryId).FirstOrDefault(); factory.FactoryDesc = factoryDesc; factory.FactoryParm.Country = countryId; factory.UserName = userName; factory.Password = password; factory.FactoryParm.StopEmployeeTime = stopEmployeeTime; factory.FactoryParm.PhoneAreaCode = phoneAreaCode; factory.FactoryParm.MapProvider = mapProvider; factory.FactoryParm.Lat = lat; factory.FactoryParm.Long = lang; factory.FactoryParm.Zoom = zoom; factory.FactoryParm.CurrentGmt = currentGmt; factory.FactoryParm.RadiusSearch = radiusSearch; factory.FactoryParm.CustomerLinkDistanceThreshold = customerLinkDistanceThreshold; factory.FactoryParm.SplitTime = splitTime; } } } catch (Exception) { } return(new JsonResult { Data = "", JsonRequestBehavior = JsonRequestBehavior.AllowGet }); }
public int SaveEmployeeData(string number, string firstName, string lastName, string startDay, string enddate, string phone1, string phone11, string phone2, string phone22, string ManufactureChoice, string phoneTypeChoice, string mail) { int factoryId = SessionManagement.FactoryID; int EmployeeID = 0; using (ISEEEntities context = new ISEEEntities()) { try { Employee emp = new Employee(); emp.FirstName = Common.Common.GetNullableValues(firstName); emp.LastName = Common.Common.GetNullableValues(lastName); emp.EmployeeNum = Common.Common.GetNullableValues(number); emp.SysCreatDate = DateTime.Now; emp.Factory = factoryId; if (string.IsNullOrEmpty(startDay)) { emp.StartDay = DateTime.Now; } else { emp.StartDay = startDay != "" ? Convert.ToDateTime(startDay).Date : emp.StartDay; } emp.EndDay = enddate != "" ? Convert.ToDateTime(enddate).Date : emp.EndDay; emp.PhoneManufactory = Convert.ToInt32(ManufactureChoice); emp.PhoneType = Convert.ToInt32(phoneTypeChoice != "" ? phoneTypeChoice : "1"); emp.SecondPhone = Common.Common.GetNullableValues(phone22); emp.SecondAreaPhone = Common.Common.GetNullableValues(phone2); emp.MainAreaPhone = Common.Common.GetNullableValues(phone1); emp.Mail = Common.Common.GetNullableValues(mail); emp.MainPhone = Common.Common.GetNullableValues(phone11); emp.EmployeeKey = Guid.NewGuid(); context.Employees.Add(emp); context.SaveChanges(); EmployeeID = emp.EmployeeId; } catch (Exception ex) { return(0); } } return(EmployeeID); }
public JsonResult GetEmployee(string firstname, string lastname, string phone) { firstname = string.IsNullOrEmpty(firstname) ? null : firstname; lastname = string.IsNullOrEmpty(lastname) ? null : lastname; phone = string.IsNullOrEmpty(phone) ? null : phone; using (ISEEEntities context = new ISEEEntities()) { int factoryId = SessionManagement.FactoryID; bool _Active = true; var empData = dataContext.Employees.Where(x => x.Factory == factoryId && x.FirstName.Contains(firstname == null ? x.FirstName : firstname) && (string.IsNullOrEmpty(lastname) || x.LastName.Contains(lastname)) && x.EmployeeNum.Contains(phone == null ? x.EmployeeNum : phone) && (_Active == true ? (x.EndDay == null || (x.EndDay != null && x.EndDay >= DateTime.Now)) : (x.EndDay != null && x.EndDay < DateTime.Now))).OrderBy(x => x.EmployeeNum).Select(x => new { FirstName = x.FirstName, LastName = x.LastName, MainPhone = x.MainPhone, id = x.EmployeeId, x.MainAreaPhone }).ToList(); return(new JsonResult { Data = empData, JsonRequestBehavior = JsonRequestBehavior.AllowGet }); } }
public JsonResult GetEmployeeByIdOnLoad(int employeeID) { if (employeeID > 0) { using (ISEEEntities context = new ISEEEntities()) { int factoryId = SessionManagement.FactoryID; var empData = _facory.GetEmployeeById(employeeID, factoryId).Select(x => new { EmployeeID = x.EmployeeId, Number = x.EmployeeNum, FirstName = x.FirstName == null ? "" : x.FirstName, LastName = x.LastName == null ? "" : x.LastName, }).ToList(); return(new JsonResult { Data = empData, JsonRequestBehavior = JsonRequestBehavior.AllowGet }); } } return(new JsonResult { Data = null, JsonRequestBehavior = JsonRequestBehavior.AllowGet }); }
public List <GoogleAddressPartsToDB> LoadCountryGoogleProps(int countryCode) { List <GoogleAddressPartsToDB> lresult = new List <GoogleAddressPartsToDB>(); using (var context = new ISEEEntities()) { var v = from c in context.GeocodeToTables join s in context.GeocodeStringResponses on c.GeocodeTagResponse equals s.GeocodeStringResponsePk where c.CountryCode == countryCode select new GoogleAddressPartsToDB() { CountryId = c.CountryCode, PartId = c.AddressTypeTable, GooglePartName = s.GeocodeTagResponse, OrderToShow = c.OrderGeocodeTagResponse, Insert = c.Insert }; lresult = v.ToList(); } return(lresult); }
public JsonResult SaveCategory(string objcategory, string objSecondary) { var MainClassification = Newtonsoft.Json.JsonConvert.DeserializeObject <List <ISEEDataModel.Repository.RequsetToFactoryLevel1> >(objcategory); var SecondaryClassification = Newtonsoft.Json.JsonConvert.DeserializeObject <List <ISEEDataModel.Repository.RequsetToFactoryLevel2[]> >(objSecondary); //List<ISEEDataModel.Repository.RequsetToFactoryLevel1> objcategory, List<ISEEDataModel.Repository.RequsetToFactoryLevel2[]> objSecondary) using (ISEEEntities db = new ISEEEntities()) { foreach (var item in MainClassification) { item.Factory = SessionManagement.FactoryID; if (db.RequsetToFactoryLevel1.Any(a => a.RequestSysIdLevel1 == item.RequestSysIdLevel1 && a.Factory == item.Factory)) // { // db.RequsetToFactoryLevel1.Attach(item); ISEEDataModel.Repository.RequsetToFactoryLevel1 objRequsetToFactoryLevel1 = db.RequsetToFactoryLevel1.Where(x => x.RequestSysIdLevel1 == item.RequestSysIdLevel1).FirstOrDefault(); //var empQuery = from RequsetToFactoryLevel1 in db.RequsetToFactoryLevel1 // where RequsetToFactoryLevel1.RequestSysIdLevel1 == item.RequestSysIdLevel1 // select RequsetToFactoryLevel1; //ISEEDataModel.Repository.RequsetToFactoryLevel1 objRequsetToFactoryLevel1 = empQuery.Single(); //set the new values of the columns (properties), based upon the values entered using the text boxes objRequsetToFactoryLevel1.Factory = item.Factory; objRequsetToFactoryLevel1.RequestDescCodeLevel1 = item.RequestDescCodeLevel1; objRequsetToFactoryLevel1.RequsetOrder = item.RequsetOrder; objRequsetToFactoryLevel1.StatusCode = item.StatusCode; db.SaveChanges(); foreach (var secondary in SecondaryClassification) { if (item.RequestSysIdLevel1 == secondary[0].RequestSysIdLevel1) { foreach (var sec in secondary) { if (db.RequsetToFactoryLevel2.Any(a => a.RequestSysIdLevel2 == sec.RequestSysIdLevel2)) // { ISEEDataModel.Repository.RequsetToFactoryLevel2 objRequsetToFactoryLevel2 = db.RequsetToFactoryLevel2.Where(x => x.RequestSysIdLevel2 == sec.RequestSysIdLevel2).FirstOrDefault(); //db.RequsetToFactoryLevel2.Attach(sec); //var Query = from RequsetToFactoryLevel2 in db.RequsetToFactoryLevel2 // where RequsetToFactoryLevel2.RequestSysIdLevel2 == sec.RequestSysIdLevel2 // select RequsetToFactoryLevel2; //ISEEDataModel.Repository.RequsetToFactoryLevel2 objRequsetToFactoryLevel2 = Query.Single(); //set the new values of the columns (properties), based upon the values entered using the text boxes objRequsetToFactoryLevel2.RequestSysIdLevel1 = sec.RequestSysIdLevel1; objRequsetToFactoryLevel2.RequestDescCodeLevel2 = sec.RequestDescCodeLevel2; objRequsetToFactoryLevel2.RequsetOrder = sec.RequsetOrder; objRequsetToFactoryLevel2.StatusCode = sec.StatusCode; db.SaveChanges(); } else { sec.CreateDate = DateTime.Now.Date; db.RequsetToFactoryLevel2.Add(sec); db.SaveChanges(); } } } } } else { var dateAndTime = DateTime.Now; item.CreateDate = dateAndTime.Date; db.RequsetToFactoryLevel1.Add(item); db.SaveChanges(); int max = db.RequsetToFactoryLevel1.Max(p => p.RequestSysIdLevel1); foreach (var secondary in SecondaryClassification) { if (item.RequestSysIdLevel1 == secondary[0].RequestSysIdLevel1) { foreach (var sec in secondary) { sec.CreateDate = dateAndTime.Date; db.RequsetToFactoryLevel2.Add(sec); db.SaveChanges(); } } } } } return(new JsonResult { Data = objcategory, JsonRequestBehavior = JsonRequestBehavior.AllowGet }); } }
public ISEEFactory() { _context = new ISEEEntities(); }
public string SendSms(string _strMsg, string phoneNumber, int employeeId) { string sss = SessionManagement.PhoneAreaCode; // string _strMsg = ""; string UserName = "******"; string Password = "******"; string msg = System.Security.SecurityElement.Escape(_strMsg); string senderName = "regionSEE"; string senderNumber = "5632455"; //set phone numbers "0545500378;0545500379;" string phonesList = SessionManagement.PhoneAreaCode + "0505774499"; //create XML StringBuilder cbXml = new StringBuilder(); cbXml.Append("<Inforu>"); cbXml.Append("<User>"); cbXml.Append("<Username>" + UserName + "</Username>"); cbXml.Append("<Password>" + Password + "</Password>"); cbXml.Append("</User>"); cbXml.Append("<Content Type=\"sms\">"); cbXml.Append("<Message>" + msg + "</Message>"); cbXml.Append("</Content>"); cbXml.Append("<Recipients>"); cbXml.Append("<PhoneNumber>" + phonesList + "</PhoneNumber>"); cbXml.Append("</Recipients>"); cbXml.Append("<Settings>"); cbXml.Append("<SenderName>" + senderName + "</SenderName>"); cbXml.Append("<SenderNumber>" + senderNumber + "</SenderNumber>"); cbXml.Append("</Settings>"); cbXml.Append("</Inforu>"); string strXML = HttpUtility.UrlEncode(cbXml.ToString(), System.Text.Encoding.UTF8); string result = PostDataToURL("http://api.inforu.co.il/SendMessageXml.ashx", "InforuXML=" + strXML); //one time get result empty(check )!!!!!! int Status = 1; if (!string.IsNullOrEmpty(result)) { XmlDocument xmlRez = new XmlDocument(); xmlRez.LoadXml(result); XmlNode xnNote = xmlRez.SelectSingleNode("Result"); Status = Convert.ToInt32(xnNote["Status"].InnerText); } //add and save row to DB EmployeeSmsSend emp_sms = new EmployeeSmsSend(); emp_sms.EmployeeId = employeeId; emp_sms.SmsCreatDate = DateTime.Now.AddHours(SessionManagement.CurrentGmt); emp_sms.SmsMsg = _strMsg; emp_sms.SmsCount = 1; emp_sms.SmsStatus = Convert.ToInt32(Status); using (ISEEEntities context = new ISEEEntities()) { context.EmployeeSmsSends.Add(emp_sms); context.SaveChanges(); } //this.ObjectContext.EmployeeSmsSend.AddObject(emp_sms); //this.ObjectContext.SaveChanges(); return(result); }