public int ConfirmMeal(EmployeeCafeteriaTransaction cafeteriaa) { try { cafeteriaa.ItemQuantity = 1; // cafeteriaa.CheckDate = DateTime.Now.Date; // cafeteriaa.UnitRate = 0; string statuss = "Yes"; Query = @"UPDATE [dbo].[EmployeeCafeteriaTransaction] SET Status = '" + statuss + "' WHERE EmpId = '" + cafeteriaa.EmpId + "' AND FoodItemCostId = '" + cafeteriaa.FoodItemCostId + "' AND CheckDate = '" + cafeteriaa.CheckDate + "' "; Command.CommandText = Query; Command.Connection = Connection; Command.Parameters.Clear(); Command.Parameters.Add("Statuss", SqlDbType.VarChar); Command.Parameters["Statuss"].Value = statuss; Connection.Open(); int rowsAffected = Command.ExecuteNonQuery(); return(rowsAffected); } catch (Exception exception) { return(0); } finally { Connection.Close(); } }
public EmployeeMonitoring GetListofuser(EmployeeCafeteriaTransaction cafeteriaa) { try { Query = @"SELECT e.EmpId, e.Name, e.JoinDate, p.Name, d.Name, g.Name, c.Number, e.Status, e.EmailId, e.EmployeePhotograph,t.ItemQuentity, t.CheckDate, t.CheckTime FROM EmployeeCafeteriaTransaction t INNER JOIN Employee e on e.Id = t.EmpId INNER JOIN Department p on p.Id = e.DepartmentId INNER JOIN Division d on d.Id = e.DivisionId INNER JOIN Designation g on g.Id = e.DesignationId INNER JOIN CardReg c on c.Id = e.CardId Where t.EmpId = '" + cafeteriaa.EmpId + "' and t.CheckDate = '" + cafeteriaa.CheckDate + "' and t.CheckTime = '" + cafeteriaa.CheckTime + "' and t.FoodItemCostId = '" + cafeteriaa.FoodItemCostId + "'"; Command.CommandText = Query; Command.Connection = Connection; Connection.Open(); Reader = Command.ExecuteReader(); EmployeeMonitoring employees = new EmployeeMonitoring(); if (Reader.HasRows) { while (Reader.Read()) { EmployeeMonitoring employee = new EmployeeMonitoring(); employee.Id = Convert.ToInt32(Reader["Id"]); employee.EmpId = Reader["EmpId"].ToString(); employee.Name = Reader["Name"].ToString(); employee.JoinDate = (DateTime)Reader["JoinDate"]; employee.Division = Reader["DivisionName"].ToString(); employee.Department = Reader["DepartmentName"].ToString(); employee.Designation = Reader["DesignationName"].ToString(); employee.CardNumber = Reader["Number"].ToString(); // employee.Status = Convert.ToBoolean(Reader["Status"].ToString()); employee.EmailId = Reader["EmailId"].ToString(); employee.UploadFile = Reader["EmployeePhotograph"].ToString(); employees = employee; } Reader.Close(); } return(employees); } catch (Exception exception) { return(null); } finally { Connection.Close(); } }
// GET: Test public ActionResult Test() { if (Session["UserRoleId"] == null) { return(RedirectToAction("Login", "Login")); } List <EmployeeCafeteriaTransaction> collectionOfTodaysMeal = _mealSchedule.GetTodaysList(); foreach (var transaction in collectionOfTodaysMeal) { EmployeeCafeteriaTransaction emptransection = new EmployeeCafeteriaTransaction(); emptransection.EmpId = transaction.EmpId; emptransection.FoodItemCostId = transaction.FoodItemCostId; string time589 = DateTime.Now.TimeOfDay.ToString(); string hh = time589.Substring(0, 2); string mm = time589.Substring(3, 2); string ss = time589.Substring(6, 2); string time = hh + ":" + mm + ":" + ss; emptransection.CheckTime = time; emptransection.CheckDate = transaction.CheckDate; if (emptransection.EmpId != null) { var employs = _employee.IsEmployeeExist(emptransection.EmpId, emptransection.FoodItemCostId, emptransection.CheckTime, emptransection.CheckDate); var employs1 = _employee.IsEmployeeExist1(emptransection.EmpId, emptransection.CheckTime, emptransection.CheckDate); if (employs == false) { // if (employs1 == false) // { int message = _employee.SaveRecord(emptransection); //var message1 = _employeeManager.GetListofuser(emptransection); // } } } } return(View()); }
public ActionResult Save(EmployeeCafeteriaTransaction cafeteriaTransaction) { cafeteriaTransaction.CheckTime = DateTime.Now.TimeOfDay.ToString(); int UPPER = cafeteriaTransaction.ItemQuantity; for (int i = 1; i <= UPPER; i++) { try { ViewBag.Message = _employee.Save(cafeteriaTransaction) ? "Employee Cafeteria Transaction Saved Successfully" : "Employee Cafeteria Transaction Save Failed"; } catch (Exception exception) { ViewBag.Message = exception.Message; } } return(View()); }
// public int SaveRecord(string empId, int foodItemId) public int SaveRecord(EmployeeCafeteriaTransaction cafeteriaa) { try { cafeteriaa.ItemQuantity = 1; // cafeteriaa.CheckDate = DateTime.Now.Date; // cafeteriaa.UnitRate = 0; string statuss = "No"; Query = "INSERT INTO EmployeeCafeteriaTransaction(EmpId, FoodItemCostId, ItemQuentity, CheckTime, CheckDate, UnitRate, Status ) VALUES(@EmpId, @FoodItemCostId, @ItemQuentity, @CheckTime, @CheckDate, @UnitRate, @statuss )"; Command.CommandText = Query; Command.Connection = Connection; Command.Parameters.Clear(); Command.Parameters.Add("EmpId", SqlDbType.VarChar); Command.Parameters["EmpId"].Value = cafeteriaa.EmpId; Command.Parameters.Add("FoodItemCostId", SqlDbType.Int); Command.Parameters["FoodItemCostId"].Value = cafeteriaa.FoodItemCostId; Command.Parameters.Add("ItemQuentity", SqlDbType.Int); Command.Parameters["ItemQuentity"].Value = cafeteriaa.ItemQuantity; Command.Parameters.Add("CheckTime", SqlDbType.VarChar); Command.Parameters["CheckTime"].Value = cafeteriaa.CheckTime; Command.Parameters.Add("CheckDate", SqlDbType.Date); Command.Parameters["CheckDate"].Value = cafeteriaa.CheckDate; Command.Parameters.Add("UnitRate", SqlDbType.Decimal); Command.Parameters["UnitRate"].Value = cafeteriaa.UnitRate; Command.Parameters.Add("Statuss", SqlDbType.VarChar); Command.Parameters["Statuss"].Value = statuss; Connection.Open(); int rowsAffected = Command.ExecuteNonQuery(); return(rowsAffected); } catch (Exception exception) { return(0); } finally { Connection.Close(); } }
public ActionResult Test1(int foodItemId) { if (Session["UserRoleId"] == null) { return(RedirectToAction("Login", "Login")); } try { string presentTime = DateTime.Now.TimeOfDay.ToString(); bool IsFoodItemTimeExist = _employeeManager.IsFoodItemTimeExist(presentTime, foodItemId); // List<ShowEmployeeMonitoring> employees1 = new List<ShowEmployeeMonitoring>(); //Queue employees1 = new Queue(); Stack employees1 = new Stack(); List <ShowEmployeeMonitoring> employees420 = new List <ShowEmployeeMonitoring>(); if (IsFoodItemTimeExist == true) { EmployeeMonitoring employ = null; string year = DateTime.Now.Year.ToString(); string month = DateTime.Now.Month.ToString(); string day = DateTime.Now.Day.ToString(); if (month.Length == 1) { month = "0" + month; } if (day.Length == 1) { day = "0" + day; } string textFile = year + month + day + ".txt"; //test 1**************** //FileStream fileStream = new FileStream(@"E:\\ATT_DATA\\" + textFile + "", FileMode.OpenOrCreate, FileAccess.ReadWrite, // FileShare.None); // StreamReader sr = new StreamReader(fileStream); //test 2**************** using (var fs = new FileStream(@"D:\\ATT_DATA\\" + textFile + "", FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) using (var sr = new StreamReader(fs, Encoding.Default)) { //Read the first line of text var line = sr.ReadLine(); List <EmployeeMonitoring> employees = new List <EmployeeMonitoring>(); employees.Clear(); //int number = 1; //Continue to read until you reach end of file while (line != null) { int index = line.IndexOf(','); string date = line.Substring(0, index); string year1 = date.Substring(0, 4); string month1 = date.Substring(4, 2); string day1 = date.Substring(6, 2); string dates = year1 + "-" + month1 + "-" + day1; DateTime dates1 = Convert.ToDateTime(dates); if (foodItemId == 9) { dates1 = dates1.AddDays(-1); } int index1 = index + 1; string time1 = line.Substring(index1, 6); int index2 = index + 8; string cardNumber = line.Substring(index2, 8); string hh = time1.Substring(0, 2); string mm = time1.Substring(2, 2); string ss = time1.Substring(4, 2); string time = hh + ":" + mm + ":" + ss; bool employs = false; bool employs1 = false; bool employs2 = false; bool IsFoodItemTimeExist1 = _employeeManager.IsFoodItemTimeExist(time, foodItemId); if (IsFoodItemTimeExist1 == true) { if (cardNumber != "") { employ = _employeeManager.GetEmployeeByEmpId(cardNumber); bool employ12 = _employeeManager.GetEmployeeByEmpId12(cardNumber, foodItemId); if (employ12 == true) { ShowEmployeeMonitoring employ1 = _employeeManager.GetEmployeeByEmpId1(cardNumber, foodItemId); var status = employees420.Find(m => m.EmpId == employ1.EmpId); if (status == null) { employees420.Add(employ1); employees1.Push(employ1); } } else { ShowEmployeeMonitoring employ1 = _employeeManager.GetEmployeeByEmpId2(cardNumber, foodItemId); var status = employees420.Find(m => m.EmpId == employ1.EmpId); if (status == null) { // employ1.Statuss = ""; employ1.Statuss = @"<p style=""color: red""> Not Listed </p>"; employees420.Add(employ1); employees1.Push(employ1); } } } EmployeeCafeteriaTransaction emptransection = new EmployeeCafeteriaTransaction(); emptransection.EmpId = employ.EmpId; emptransection.FoodItemCostId = foodItemId; emptransection.CheckTime = time; emptransection.CheckDate = dates1.ToString(); if (emptransection.EmpId != null) { employs = _employee.IsEmployeeExist0901(emptransection.EmpId, foodItemId, time, dates); employs1 = _employee.IsEmployeeExist09011(emptransection.EmpId, time, dates, foodItemId); employs2 = _employee.IsEmployeeExist090112(emptransection.EmpId, time, dates, foodItemId); if (employs == false) { if (employs1 == false) { if (employs2 == false) { int message = _employee.SaveRecord1(emptransection); } } } employs = _employee.IsEmployeeExist191(emptransection.EmpId, foodItemId, time, dates); employs1 = _employee.IsEmployeeExist101(emptransection.EmpId, time, dates); if (employs == true) { if (employs1 == true) { int message = _employee.ConfirmMeal(emptransection); var message1 = _employeeManager.GetListofuser(emptransection); } } } } //Read the next line line = sr.ReadLine(); } //close the file sr.Close(); } } return(Json(employees1, JsonRequestBehavior.AllowGet)); } catch (Exception e) { return(null); } }
public JsonResult Import(HttpPostedFileBase Textfile) { HttpPostedFileBase file = Request.Files[0]; // your file EmployeeMonitoring employ = null; Stack employees1 = new Stack(); string imageUrl = ""; if (file != null) { if (file.ContentType == "text/plain") { var imageType = file.ContentType; if (imageType == "text/plain") { imageUrl = "123" + ".txt"; } file.SaveAs(Server.MapPath("/") + "/UploadFile/" + imageUrl); } } // StreamReader sr = new StreamReader(Server.MapPath("/") + "/UploadFile/" + imageUrl); using (var fs = new FileStream(Server.MapPath(" / ") + "/UploadFile/" + imageUrl, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) using (var sr = new StreamReader(fs, Encoding.Default)) { //Read the first line of text var line = sr.ReadLine(); List <EmployeeMonitoring> employees = new List <EmployeeMonitoring>(); employees.Clear(); //int number = 1; //Continue to read until you reach end of file while (line != null) { int index = line.IndexOf(','); string date = line.Substring(0, index); string year1 = date.Substring(0, 4); string month1 = date.Substring(4, 2); string day1 = date.Substring(6, 2); string dates = year1 + "-" + month1 + "-" + day1; DateTime dates1 = Convert.ToDateTime(dates); int index1 = index + 1; string time1 = line.Substring(index1, 6); int index2 = index + 8; string cardNumber = line.Substring(index2, 8); string hh = time1.Substring(0, 2); string mm = time1.Substring(2, 2); string ss = time1.Substring(4, 2); string time = hh + ":" + mm + ":" + ss; bool employs = false; bool employs1 = false; int foodItemId = _employeeManager.GetFoodItemCostIdByTime(time); if (foodItemId == 9) { dates1 = dates1.AddDays(-1); } bool IsFoodItemTimeExist1 = _employeeManager.IsFoodItemTimeExist(time, foodItemId); if (IsFoodItemTimeExist1 == true) { if (cardNumber != "") { employ = _employeeManager.GetEmployeeByEmpId(cardNumber); //bool employ12 = _employeeManager.GetEmployeeByEmpId123(cardNumber, foodItemId, dates); //if (employ12 == true) //{ // ShowEmployeeMonitoring employ1 = _employeeManager.GetEmployeeByEmpId1(cardNumber, foodItemId); // // employees1.Add(employ1); // // employees1.Enqueue(employ1); // employees1.Push(employ1); //} } EmployeeCafeteriaTransaction emptransection = new EmployeeCafeteriaTransaction(); emptransection.EmpId = employ.EmpId; emptransection.FoodItemCostId = foodItemId; emptransection.CheckTime = time; emptransection.CheckDate = dates1.ToString(); if (emptransection.EmpId != null) { employs = _employee.IsEmployeeExist(emptransection.EmpId, foodItemId, time, dates); employs1 = _employee.IsEmployeeExist1(emptransection.EmpId, time, dates); if (employs == false) { if (employs1 == false) { int message = _employee.SaveRecord(emptransection); // var message1 = _employeeManager.GetListofuser(emptransection); bool employ12 = _employeeManager.GetEmployeeByEmpId123(cardNumber, foodItemId, dates); if (employ12 == true) { ShowEmployeeMonitoring employ1 = _employeeManager.GetEmployeeByEmpId1235(cardNumber, foodItemId, dates); // employees1.Add(employ1); // employees1.Enqueue(employ1); employees1.Push(employ1); } } } } } //Read the next line line = sr.ReadLine(); } //close the file sr.Close(); } //Read the first line of text //var line = sr.ReadLine(); //List<EmployeeMonitoring> employees = new List<EmployeeMonitoring>(); //List<ShowEmployeeMonitoring> employees1 = new List<ShowEmployeeMonitoring>(); //employees.Clear(); ////int number = 1; ////Continue to read until you reach end of file //while (line != null) //{ // int index = line.IndexOf(','); // string date = line.Substring(0, index); // string year = date.Substring(0, 4); // string month = date.Substring(4, 2); // string day = date.Substring(6, 2); // string dates = year + "-" + month + "-" + day; // int index1 = index + 1; // string time1 = line.Substring(index1, 6); // int index2 = index + 8; // string cardNumber = line.Substring(index2, 8); // string hh = time1.Substring(0, 2); // string mm = time1.Substring(2, 2); // string ss = time1.Substring(4,2); // string time = hh + ":" + mm + ":" + ss; // int foodItemId = 0; // bool employs = false; // bool employs1 = false; // if (cardNumber != "") // { // foodItemId = _employeeManager.GetFoodItemCostIdByTime(time); // employ = _employeeManager.GetEmployeeByEmpId(cardNumber); // ShowEmployeeMonitoring employ1 = _employeeManager.GetEmployeeByEmpId1(cardNumber, foodItemId); // employees1.Add(employ1); // //employees1.Add(number); // // number++; // } // EmployeeCafeteriaTransaction emptransection = new EmployeeCafeteriaTransaction(); // emptransection.EmpId = employ.EmpId; // emptransection.FoodItemCostId = foodItemId; // emptransection.CheckTime = time; // emptransection.CheckDate = dates; // employs = _employee.IsEmployeeExist(emptransection.EmpId, foodItemId, time, dates); // employs1 = _employee.IsEmployeeExist1(emptransection.EmpId, time, dates); // if (employs == false) // { // if (employs1 == false) // { // int message = _employee.SaveRecord(emptransection); // var message1 = _employeeManager.GetListofuser(emptransection); // //employees.Add(message1); // //employ.Number = number; // //number++; // } // } // //Read the next line // line = sr.ReadLine(); //} ////close the file //sr.Close(); string fullPath = Request.MapPath("~/UploadFile/" + imageUrl); if (System.IO.File.Exists(fullPath)) { System.IO.File.Delete(fullPath); } return(Json(employees1, JsonRequestBehavior.AllowGet)); }
public int ConfirmMeal(EmployeeCafeteriaTransaction cafeteriaa) { return(_employee.ConfirmMeal(cafeteriaa)); }
public int SaveRecord1(EmployeeCafeteriaTransaction cafeteriaa) { return(_employee.SaveRecord1(cafeteriaa)); }
public bool Save(EmployeeCafeteriaTransaction cafeteria) { return(_employee.Save(cafeteria) > 0); }
public EmployeeMonitoring GetListofuser(EmployeeCafeteriaTransaction cafeteriaa) { return(employeeGateway.GetListofuser(cafeteriaa)); }
public List <EmployeeCafeteriaTransaction> GetTodaysList() { try { string date = DateTime.Now.ToString("yyyy-MM-dd"); Query = "SELECT * FROM MealSchedule Where Date = '" + date + "' AND Status = '" + "Pending" + "' "; Command.CommandText = Query; Command.Connection = Connection; Connection.Open(); Reader = Command.ExecuteReader(); List <EmployeeCafeteriaTransaction> tdaysLists = new List <EmployeeCafeteriaTransaction>(); if (Reader.HasRows) { while (Reader.Read()) { EmployeeCafeteriaTransaction list = new EmployeeCafeteriaTransaction(); list.Id = Convert.ToInt32(Reader["Id"]); list.EmpId = Reader["EmpId"].ToString(); list.CheckDate = Reader["Date"].ToString(); list.FoodItemCostId = (int)Reader["ItemId"]; list.Status = Reader["Status"].ToString(); list.ItemQuantity = (int)Reader["Quantity"]; tdaysLists.Add(list); } Reader.Close(); Connection.Close(); } foreach (var item in tdaysLists) { string status = "Confirm"; int id = item.Id; Query = @"UPDATE MealSchedule SET Status = @status WHERE Id = '" + id + "'"; Command.CommandText = Query; Command.Connection = Connection; Command.Parameters.Clear(); Command.Parameters.Add("status", SqlDbType.VarChar); Command.Parameters["status"].Value = status; Connection.Open(); int rowsAffected = Command.ExecuteNonQuery(); Connection.Close(); } return(tdaysLists); } catch (Exception exception) { return(null); } finally { Connection.Close(); } }