public bool InsertRoasterDetail(RoasterManagement RoasterManagement) { bool isFlag = false; RoasterManagementDLL objRoasterManagementDLL = null; try { objRoasterManagementDLL = new RoasterManagementDLL(); isFlag = objRoasterManagementDLL.InsertRosterDetail(RoasterManagement); } catch(Exception ex) { throw; } finally { objRoasterManagementDLL = null; } return isFlag; }
public static Object InsertRoasterManagement(string rosterdetail) { bool insertFlag = false; //bool UpdateFlag = false; string roosterNumber = string.Empty; ArrayList roosterNumberlist = new ArrayList(); IEnumerable<dynamic> intersectResult = null; List<Roster> RosterDetails = null; RoasterManagementBLL objRoasterManagementBLL = null; RoasterManagement objRoasterManagement = null; try { objRoasterManagementBLL = new RoasterManagementBLL(); objRoasterManagement = new RoasterManagement(); objRoasterManagement.PreFix = System.DateTime.Now.ToString("yyMMdd"); bool CreateRosterNoFlag=false; RosterDetails = objRoasterManagementBLL.GetRoasterDetail(objRoasterManagement.PreFix); int commonRow = 0; DataTable dt = new DataTable(); dt = RosterDt.Copy(); if (RosterDetails != null) { var query1 = dt.AsEnumerable().Select(a => new { CabNo = a["CabNo"].ToString(), ShiftTime = Convert.ToDateTime(a["Shift Timings"]).TimeOfDay.ToString(), RoosterDate = Convert.ToDateTime(a["Date"]).ToShortDateString(), }); var query2 = RosterDetails.AsEnumerable().Select(b => new { CabNo = b.Cabno, ShiftTime = b.ShiftTime, RoosterDate = Convert.ToDateTime(b.RousterDate).ToShortDateString() }); intersectResult = query1.Intersect(query2);//existing row commonRow = intersectResult.Count(); } if (commonRow == 0)//there is no duplicate record in database { var distinctCabs = dt.AsEnumerable().Select(a => new { CabNo = a["CabNo"].ToString(), ShiftTime = Convert.ToDateTime(a["Shift Timings"]).TimeOfDay.ToString(), RoosterDate = Convert.ToDateTime(a["Date"]).ToShortDateString() }).Distinct(); foreach (var c in distinctCabs) { CreateRosterNoFlag = CreateRosterNo(objRoasterManagement.PreFix, out roosterNumber); //roosterNumberlist.Add(roosterNumber); if (CreateRosterNoFlag == true)//insert { roosterNumberlist.Add(roosterNumber); objRoasterManagement.RosterDetailDT = new DataTable(); var rows = from row in dt.AsEnumerable() where row.Field<string>("CabNo").Trim() == c.CabNo && row.Field<DateTime>("Shift Timings").TimeOfDay == Convert.ToDateTime(c.ShiftTime).TimeOfDay && Convert.ToDateTime(row.Field<string>("Date")).ToShortDateString()== Convert.ToDateTime(c.RoosterDate).ToShortDateString() select row; objRoasterManagement.RosterDetailDT = rows.CopyToDataTable(); insertFlag = objRoasterManagementBLL.InsertRoasterDetail(objRoasterManagement); } } } } catch (Exception ex) { Common.WriteError(ex); } finally { objRoasterManagementBLL = null; } var result = new { Flag = insertFlag, roosternumber = roosterNumberlist, commonrow = intersectResult }; return result; }
public bool UpdateRosterDetail(RoasterManagement RoasterManagement) { bool isFlag = false; try { ObjSqlHelper = new SqlHelper.SqlHelper(); string proc_name = ConstantsDLL.USP_UPDATEROASTERDETAIL; SqlParameter[] param = new SqlParameter[1]; //param[0] = new SqlParameter("@PreFix", RoasterManagement.PreFix); //param[0] = new SqlParameter("@Client", RoasterManagement.Client); //param[1] = new SqlParameter("@ProjectCode", RoasterManagement.ProjectCode); //param[2] = new SqlParameter("@PickupDropDate", RoasterManagement.PickupDropDate); //param[3] = new SqlParameter("@TotalEmployee", RoasterManagement.TotalEmployee); //param[4] = new SqlParameter("@RouteName", RoasterManagement.RouteName); //param[5] = new SqlParameter("@LandmarkName", RoasterManagement.LandmarkName); //param[6] = new SqlParameter("@TypeOfPickupDrop", RoasterManagement.TypeOfPickupDrop); //param[7] = new SqlParameter("@ShiftTimings", RoasterManagement.ShiftTimings); //param[8] = new SqlParameter("@CabType", RoasterManagement.CabType); //param[9] = new SqlParameter("@Vendor", RoasterManagement.Vendor); //param[10] = new SqlParameter("@EndUser", RoasterManagement.EndUser); //param[11] = new SqlParameter("@Guard", RoasterManagement.Guard); //param[12] = new SqlParameter("@CabNo", RoasterManagement.CabNo); DataTable dt = new DataTable(); dt = RoasterManagement.RosterDetailDT; dt.Columns.Remove("Row"); dt.Columns.Remove("CabNoValid"); dt.Columns.Remove("RouteNameValid"); dt.Columns.Remove("Signature"); dt.Columns.Remove("CabCapacityValid"); dt.Columns.Remove("CabPropertyValid"); dt.Columns.Remove("EmployeNoValid"); dt.Columns.Remove("CabCapacity"); param[0] = new SqlParameter("@TableVar", dt); ObjSqlHelper.ExecNonQueryProc(proc_name, param); isFlag = true; } catch (Exception ex) { isFlag = false; throw; } return isFlag; }
/// <summary> /// Method to Insert Roaster /// </summary> /// <returns></returns> public bool InsertRosterDetail(RoasterManagement RoasterManagement) { bool isFlag = false; try { ObjSqlHelper = new SqlHelper.SqlHelper(); string proc_name = ConstantsDLL.USP_INSERTROASTERDETAIL; SqlParameter[] param = new SqlParameter[1]; DataTable dt = new DataTable(); dt=RoasterManagement.RosterDetailDT; dt.Columns.Remove("Row"); dt.Columns.Remove("CabNoValid"); dt.Columns.Remove("RouteNameValid"); dt.Columns.Remove("Signature"); dt.Columns.Remove("CabCapacityValid"); dt.Columns.Remove("CabPropertyValid"); dt.Columns.Remove("EmployeNoValid"); dt.Columns.Remove("CabCapacity"); param[0] = new SqlParameter("@TableVar", dt); ObjSqlHelper.ExecNonQueryProc(proc_name, param); isFlag=true; } catch(Exception ex) { isFlag = false; throw; } return isFlag; }