public DataTable FamerDetails() { return(Farmer_DL.FamerDetails()); }
public DataTable FamerDetails(string farmerName, string farmerCode, string area) { return(Farmer_DL.FamerDetails(farmerName, farmerCode, area)); }
public DataTable FamerDetails(string farmerCode) { return(Farmer_DL.FamerDetails(farmerCode)); }
public DataTable NewPlanDetails(int year, decimal DaysPerFarmer, DateTime startDate, DateTime endDate, string role) { DataTable FarmerTable = Farmer_DL.FamerDetails(); DataRow[] drEmployees = (BranchsRolesEmployees_DL.GetEmployeeWithRoles()).Select("Roleid ='" + role + "'"); DataTable dtNewPlan = new DataTable(); DataTable dtHolidays = Holidays(year, startDate, endDate); dtNewPlan.Columns.Add("FarmerID"); dtNewPlan.Columns.Add("FarmerName"); dtNewPlan.Columns.Add("FarmerCode"); dtNewPlan.Columns.Add("FarmerArea"); dtNewPlan.Columns.Add("InspectorID"); dtNewPlan.Columns.Add("InspectorName"); dtNewPlan.Columns.Add("PlanDate"); dtNewPlan.Columns.Add("VisitedDate"); dtNewPlan.Columns.Add("InspectionID"); int employeecount = 0; DateTime planDate = startDate; foreach (DataRow drFarmer in FarmerTable.Rows) { DataRow newrow = dtNewPlan.NewRow(); newrow["InspectionID"] = "0"; newrow["FarmerID"] = drFarmer["FarmerID"]; newrow["FarmerName"] = drFarmer["FirstName"]; newrow["FarmerCode"] = drFarmer["FarmerCode"]; newrow["FarmerArea"] = drFarmer["City_Village"]; if (employeecount < drEmployees.Length) { DataRow dremp = drEmployees[employeecount]; newrow["InspectorID"] = dremp["EmployeeID"]; newrow["InspectorName"] = dremp["EmployeeFristName"]; employeecount += 1; if (employeecount == drEmployees.Length) { employeecount = 0; } } if (planDate >= startDate && planDate <= endDate) { if (planDate.DayOfWeek.ToString().ToLower() == "sunday") { planDate = planDate.AddDays(1); } if (planDate.DayOfWeek.ToString().ToLower() != "sunday") { for (int hcount = 0; hcount < dtHolidays.Rows.Count; hcount++) { if (DateTime.Compare(planDate, Convert.ToDateTime(dtHolidays.Rows[hcount]["HolidayDate"].ToString().Trim())) == 0) { planDate = planDate.AddDays(1); hcount = -1; } } if (planDate.DayOfWeek.ToString().ToLower() == "sunday") { planDate = planDate.AddDays(1); } newrow["PlanDate"] = planDate.ToShortDateString(); newrow["VisitedDate"] = planDate.ToShortDateString(); //newrow["PlanDate"] = string.Format("{0:dd MMM yyyy}",planDate.ToShortDateString()); //newrow["VisitedDate"] = string.Format("{0:dd MMM yyyy}",planDate.ToShortDateString()); planDate = planDate.AddDays(1); if (planDate > endDate) { planDate = startDate; } } } dtNewPlan.Rows.Add(newrow); } planDate = planDate.AddDays(1); if (planDate > endDate) { planDate = startDate; } //old code //DataTable FarmerTable = Farmer_DL.FamerDetails(); //DataTable dtHolidays = Holidays(year, startDate, endDate); //DateTime planDate = startDate; //foreach (DataRow drFarmer in FarmerTable.Rows) //{ // DataRow newrow = dtNewPlan.NewRow(); // newrow["InspectionID"] = "0"; // newrow["FarmerID"] = drFarmer["FarmerID"]; // newrow["FarmerName"] = drFarmer["FirstName"]; // newrow["FarmerCode"] = drFarmer["FarmerCode"]; // newrow["FarmerArea"] = drFarmer["City_Village"]; // DataTable farmervillages = UnitInformation_DL.FarmersVillageList(); // string village = string.Empty; // for (int i = 0; i < farmervillages.Rows.Count; i++) // { // Random random = new Random(); // int getID = random.Next(0, farmervillages.Rows.Count); // village = farmervillages.Rows[getID]["City_Village"].ToString(); // DataTable EmployeeTable = BranchsRolesEmployees_DL.GetEmployeBasedonRoleID(role); // string empID = string.Empty; // string empname = string.Empty; // if (EmployeeTable.Rows.Count > 0) // { // Random random1 = new Random(); // int getunitID = random1.Next(0, EmployeeTable.Rows.Count); // if (count == 0) // { // newrow["InspectorID"] = EmployeeTable.Rows[getunitID]["EmployeeId"].ToString(); // newrow["InspectorName"] = EmployeeTable.Rows[getunitID]["EmployeeFristName"].ToString(); // count++; // } // else // { // newrow["InspectorID"] = EmployeeTable.Rows[getunitID]["EmployeeId"].ToString(); // newrow["InspectorName"] = EmployeeTable.Rows[getunitID]["EmployeeFristName"].ToString(); // count = getID; // } // } // if (planDate >= startDate && planDate <= endDate) // { // if (planDate.DayOfWeek.ToString().ToLower() == "sunday") // { // planDate = planDate.AddDays(1); // } // if (planDate.DayOfWeek.ToString().ToLower() != "sunday") // { // for (int hcount = 0; hcount < dtHolidays.Rows.Count; hcount++) // { // if (DateTime.Compare(planDate, Convert.ToDateTime(dtHolidays.Rows[hcount]["HolidayDate"].ToString().Trim())) == 0) // { // planDate = planDate.AddDays(1); // hcount = -1; // } // } // if (planDate.DayOfWeek.ToString().ToLower() == "sunday") // { // planDate = planDate.AddDays(1); // } // newrow["PlanDate"] = planDate.ToShortDateString(); // newrow["VisitedDate"] = planDate.ToShortDateString(); // planDate = planDate.AddDays(1); // if (planDate > endDate) // { // planDate = startDate; // } // } // } // } // dtNewPlan.Rows.Add(newrow); //} return(dtNewPlan); }