Exemple #1
0
        public DataTable FarmDetails(string FarmerId, bool IsParent)
        {
            DataTable dtFarm       = Farmer_DL.FarmDetails(FarmerId);
            DataTable dtFarmResult = dtFarm.Clone();

            if (dtFarm.Rows.Count > 0)
            {
                string condtion = string.Empty;
                if (IsParent)
                {
                    condtion = " ParentFarmID = 0";
                }
                else
                {
                    condtion = " ParentFarmID > 0";
                }
                DataRow[] drs = dtFarm.Select(condtion);
                foreach (DataRow dr in drs)
                {
                    dtFarmResult.ImportRow(dr);
                }
            }
            return(dtFarmResult);
        }
Exemple #2
0
 public DataTable FarmDetails(string FarmerId)
 {
     return(Farmer_DL.FarmDetails(FarmerId));
 }
        public DataTable BuildNEWPlantation(int Year, int SeasonID, int ProdcutID)
        {
            DataTable dtFarmer  = Farmer_DL.FarmDetails();
            DataTable dtProduct = Product_DL.GetProductDetailsbySeason(SeasonID);
            DataTable dtSeason  = CategoryProduct_DL.GetSeasonDetails(SeasonID);

            DataTable NewPlantation = new DataTable();

            NewPlantation.Columns.Add("FarmerId");
            NewPlantation.Columns.Add("FarmerCode");
            NewPlantation.Columns.Add("FirstName");
            NewPlantation.Columns.Add("FarmerRegNumber");
            NewPlantation.Columns.Add("TotalAreaInHectares");
            NewPlantation.Columns.Add("FarmID");
            NewPlantation.Columns.Add("AreaCode");
            NewPlantation.Columns.Add("PlotArea");
            NewPlantation.Columns.Add("SeasonID");

            if (ProdcutID == 0)
            {
                foreach (DataRow dr in dtProduct.Rows)
                {
                    NewPlantation.Columns.Add("ProductId" + "_" + dr["ProductId"]);
                    NewPlantation.Columns.Add("PlantationId" + "_" + dr["ProductId"]);
                    NewPlantation.Columns.Add("PlantationArea" + "_" + dr["ProductId"]);
                    NewPlantation.Columns.Add("PlantationDate" + "_" + dr["ProductId"]);
                    NewPlantation.Columns.Add("FirstHarvestDate" + "_" + dr["ProductId"]);
                    NewPlantation.Columns.Add("FirstHerbaga" + "_" + dr["ProductId"]);
                    NewPlantation.Columns.Add("FirstDistillationDate" + "_" + dr["ProductId"]);
                    NewPlantation.Columns.Add("FirstDistillationUnitNO" + "_" + dr["ProductId"]);
                    NewPlantation.Columns.Add("FirstProductQuantity" + "_" + dr["ProductId"]);
                    NewPlantation.Columns.Add("SecondHarvestDate" + "_" + dr["ProductId"]);
                    NewPlantation.Columns.Add("SecondHerbaga" + "_" + dr["ProductId"]);
                    NewPlantation.Columns.Add("SecondDistillationDate" + "_" + dr["ProductId"]);
                    NewPlantation.Columns.Add("SecondDistillationUnitNO" + "_" + dr["ProductId"]);
                    NewPlantation.Columns.Add("SecondProductQuantity" + "_" + dr["ProductId"]);
                    NewPlantation.Columns.Add("TotalProductQuantity" + "_" + dr["ProductId"]);
                }
            }
            else
            {
                NewPlantation.Columns.Add("ProductId");
                NewPlantation.Columns.Add("PlantationId");
                NewPlantation.Columns.Add("PlantationArea");
                NewPlantation.Columns.Add("PlantationDate");
                NewPlantation.Columns.Add("FirstHarvestDate");
                NewPlantation.Columns.Add("FirstHerbaga");
                NewPlantation.Columns.Add("FirstDistillationDate");
                NewPlantation.Columns.Add("FirstDistillationUnitNO");
                NewPlantation.Columns.Add("FirstProductQuantity");
                NewPlantation.Columns.Add("SecondHarvestDate");
                NewPlantation.Columns.Add("SecondHerbaga");
                NewPlantation.Columns.Add("SecondDistillationDate");
                NewPlantation.Columns.Add("SecondDistillationUnitNO");
                NewPlantation.Columns.Add("SecondProductQuantity");
                NewPlantation.Columns.Add("TotalProductQuantity");
            }
            int DateCount = 0;

            foreach (DataRow drFarmer in dtFarmer.Rows)
            {
                DataRow newdr    = NewPlantation.NewRow();
                DataRow drseason = dtSeason.Rows[0];
                newdr["FarmerId"]            = drFarmer["FarmerId"];
                newdr["FarmerCode"]          = drFarmer["FarmerCode"];
                newdr["FirstName"]           = drFarmer["FirstName"];
                newdr["FarmerRegNumber"]     = drFarmer["FarmerRegNumber"];
                newdr["TotalAreaInHectares"] = drFarmer["TotalAreaInHectares"];
                newdr["FarmID"]   = drFarmer["FarmID"];
                newdr["AreaCode"] = drFarmer["AreaCode"];
                newdr["PlotArea"] = drFarmer["PlotArea"];
                newdr["SeasonID"] = SeasonID;
                if (ProdcutID > 0)
                {
                    newdr["ProductId"]                = ProdcutID;
                    newdr["PlantationId"]             = "0";
                    newdr["PlantationArea"]           = "0";
                    newdr["PlantationDate"]           = Convert.ToDateTime(drseason["StartDate"].ToString()).AddDays(DateCount).ToShortDateString();
                    newdr["FirstHarvestDate"]         = (Convert.ToDateTime(drseason["StartDate"].ToString()).AddDays(DateCount + 100)).ToShortDateString();
                    newdr["FirstHerbaga"]             = "0";
                    newdr["FirstDistillationDate"]    = (Convert.ToDateTime(drseason["StartDate"].ToString()).AddDays(DateCount + 101)).ToShortDateString();
                    newdr["FirstDistillationUnitNO"]  = "0";
                    newdr["FirstProductQuantity"]     = "0";
                    newdr["SecondHarvestDate"]        = (Convert.ToDateTime(drseason["StartDate"].ToString()).AddDays(DateCount + 145)).ToShortDateString();;
                    newdr["SecondHerbaga"]            = "0";
                    newdr["SecondDistillationDate"]   = (Convert.ToDateTime(drseason["StartDate"].ToString()).AddDays(DateCount + 146)).ToShortDateString();;
                    newdr["SecondDistillationUnitNO"] = "0";
                    newdr["SecondProductQuantity"]    = "0";
                    newdr["TotalProductQuantity"]     = "0";
                }
                else
                {
                    foreach (DataRow dr in dtProduct.Rows)
                    {
                        newdr["ProductId" + "_" + dr["ProductId"]]                = dr["ProductId"];
                        newdr["PlantationId" + "_" + dr["ProductId"]]             = "0";
                        newdr["PlantationArea" + "_" + dr["ProductId"]]           = "0";
                        newdr["PlantationDate" + "_" + dr["ProductId"]]           = Convert.ToDateTime(drseason["StartDate"].ToString()).AddDays(DateCount).ToShortDateString();
                        newdr["FirstHarvestDate" + "_" + dr["ProductId"]]         = (Convert.ToDateTime(drseason["StartDate"].ToString()).AddDays(DateCount + 100)).ToShortDateString();
                        newdr["FirstHerbaga" + "_" + dr["ProductId"]]             = "0";
                        newdr["FirstDistillationDate" + "_" + dr["ProductId"]]    = (Convert.ToDateTime(drseason["StartDate"].ToString()).AddDays(DateCount + 101)).ToShortDateString();
                        newdr["FirstDistillationUnitNO" + "_" + dr["ProductId"]]  = "0";
                        newdr["FirstProductQuantity" + "_" + dr["ProductId"]]     = "0";
                        newdr["SecondHarvestDate" + "_" + dr["ProductId"]]        = (Convert.ToDateTime(drseason["StartDate"].ToString()).AddDays(DateCount + 145)).ToShortDateString();;
                        newdr["SecondHerbaga" + "_" + dr["ProductId"]]            = "0";
                        newdr["SecondDistillationDate" + "_" + dr["ProductId"]]   = (Convert.ToDateTime(drseason["StartDate"].ToString()).AddDays(DateCount + 146)).ToShortDateString();;
                        newdr["SecondDistillationUnitNO" + "_" + dr["ProductId"]] = "0";
                        newdr["SecondProductQuantity" + "_" + dr["ProductId"]]    = "0";
                        newdr["TotalProductQuantity" + "_" + dr["ProductId"]]     = "0";
                    }
                }
                if (DateCount < dtFarmer.Rows.Count)
                {
                    DateCount += 1;
                    if (Convert.ToDateTime(drseason["StartDate"].ToString()).AddDays(DateCount) > Convert.ToDateTime(drseason["EndDate"].ToString()))
                    {
                        DateCount = 0;
                    }
                }
                NewPlantation.Rows.Add(newdr);
            }


            return(NewPlantation);
        }