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);
        }
        public DataTable BuildPlantation(int Year, int SeasonID, int ProdcutID)
        {
            DataTable dtProduct = new DataTable();

            if (ProdcutID > 0)
            {
                dtProduct = Product_DL.GetProductDetails(ProdcutID);
            }
            else
            {
                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 count = 0, rowcount = 0;

            foreach (DataRow drproduct in dtProduct.Rows)
            {
                DataTable dtplantation = FarmPlantation_DL.BuildPlantation(Year, SeasonID, Convert.ToInt32(drproduct["ProductId"].ToString()));
                rowcount = 0;
                foreach (DataRow drplantation in dtplantation.Rows)
                {
                    DataRow newdr    = NewPlantation.NewRow();
                    DataRow drseason = dtSeason.Rows[0];
                    newdr["FarmerId"]            = drplantation["FarmerId"];
                    newdr["FarmerCode"]          = drplantation["FarmerCode"];
                    newdr["FirstName"]           = drplantation["FirstName"];
                    newdr["FarmerRegNumber"]     = drplantation["FarmerRegNumber"];
                    newdr["TotalAreaInHectares"] = drplantation["TotalAreaInHectares"];
                    newdr["FarmID"]   = drplantation["FarmID"];
                    newdr["AreaCode"] = drplantation["AreaCode"];
                    newdr["PlotArea"] = drplantation["PlotArea"];
                    newdr["SeasonID"] = SeasonID;
                    if (ProdcutID > 0)
                    {
                        newdr["ProductId"]                = ProdcutID;
                        newdr["PlantationId"]             = drplantation["PlantationId"];
                        newdr["PlantationArea"]           = drplantation["PlantationArea"];
                        newdr["PlantationDate"]           = drplantation["PlantationDate"];           //Convert.ToDateTime(drseason["StartDate"].ToString()).ToShortDateString();
                        newdr["FirstHarvestDate"]         = drplantation["FirstHarvestDate"];         //(Convert.ToDateTime(drseason["StartDate"].ToString()).AddDays(100)).ToShortDateString();
                        newdr["FirstHerbaga"]             = drplantation["FirstHerbaga"];             //"0";
                        newdr["FirstDistillationDate"]    = drplantation["FirstDistillationDate"];    //(Convert.ToDateTime(drseason["StartDate"].ToString()).AddDays(101)).ToShortDateString();
                        newdr["FirstDistillationUnitNO"]  = drplantation["FirstDistillationUnitNO"];  //"0";
                        newdr["FirstProductQuantity"]     = drplantation["FirstProductQuantity"];     //"0";
                        newdr["SecondHarvestDate"]        = drplantation["SecondHarvestDate"];        //(Convert.ToDateTime(drseason["StartDate"].ToString()).AddDays(145)).ToShortDateString(); ;
                        newdr["SecondHerbaga"]            = drplantation["SecondHerbaga"];            //"0";
                        newdr["SecondDistillationDate"]   = drplantation["SecondDistillationDate"];   //(Convert.ToDateTime(drseason["StartDate"].ToString()).AddDays(146)).ToShortDateString(); ;
                        newdr["SecondDistillationUnitNO"] = drplantation["SecondDistillationUnitNO"]; //"0";
                        newdr["SecondProductQuantity"]    = drplantation["SecondProductQuantity"];    //"0";
                        newdr["TotalProductQuantity"]     = drplantation["TotalProductQuantity"];     //"0";
                    }
                    else
                    {
                        if (count == 0)
                        {
                            newdr["ProductId" + "_" + drproduct["ProductId"]]                = drproduct["ProductId"];
                            newdr["PlantationId" + "_" + drproduct["ProductId"]]             = drplantation["PlantationId"];             //"0";
                            newdr["PlantationArea" + "_" + drproduct["ProductId"]]           = drplantation["PlantationArea"];           //"0";
                            newdr["PlantationDate" + "_" + drproduct["ProductId"]]           = drplantation["PlantationDate"];           //Convert.ToDateTime(drseason["StartDate"].ToString()).ToShortDateString();
                            newdr["FirstHarvestDate" + "_" + drproduct["ProductId"]]         = drplantation["FirstHarvestDate"];         // (Convert.ToDateTime(drseason["StartDate"].ToString()).AddDays(100)).ToShortDateString();
                            newdr["FirstHerbaga" + "_" + drproduct["ProductId"]]             = drplantation["FirstHerbaga"];             // "0";
                            newdr["FirstDistillationDate" + "_" + drproduct["ProductId"]]    = drplantation["FirstDistillationDate"];    // (Convert.ToDateTime(drseason["StartDate"].ToString()).AddDays(101)).ToShortDateString();
                            newdr["FirstDistillationUnitNO" + "_" + drproduct["ProductId"]]  = drplantation["FirstDistillationUnitNO"];  // "0";
                            newdr["FirstProductQuantity" + "_" + drproduct["ProductId"]]     = drplantation["FirstProductQuantity"];     // "0";
                            newdr["SecondHarvestDate" + "_" + drproduct["ProductId"]]        = drplantation["SecondHarvestDate"];        // (Convert.ToDateTime(drseason["StartDate"].ToString()).AddDays(145)).ToShortDateString(); ;
                            newdr["SecondHerbaga" + "_" + drproduct["ProductId"]]            = drplantation["SecondHerbaga"];            // "0";
                            newdr["SecondDistillationDate" + "_" + drproduct["ProductId"]]   = drplantation["SecondDistillationDate"];   // (Convert.ToDateTime(drseason["StartDate"].ToString()).AddDays(146)).ToShortDateString(); ;
                            newdr["SecondDistillationUnitNO" + "_" + drproduct["ProductId"]] = drplantation["SecondDistillationUnitNO"]; // "0";
                            newdr["SecondProductQuantity" + "_" + drproduct["ProductId"]]    = drplantation["SecondProductQuantity"];    // "0";
                            newdr["TotalProductQuantity" + "_" + drproduct["ProductId"]]     = drplantation["TotalProductQuantity"];     // "0";
                        }
                        if (count > 0)
                        {
                            if (rowcount < NewPlantation.Rows.Count)
                            {
                                NewPlantation.Rows[rowcount]["ProductId" + "_" + drproduct["ProductId"]]                = drproduct["ProductId"];
                                NewPlantation.Rows[rowcount]["PlantationId" + "_" + drproduct["ProductId"]]             = drplantation["PlantationId"];             //"0";
                                NewPlantation.Rows[rowcount]["PlantationArea" + "_" + drproduct["ProductId"]]           = drplantation["PlantationArea"];           //"0";
                                NewPlantation.Rows[rowcount]["PlantationDate" + "_" + drproduct["ProductId"]]           = drplantation["PlantationDate"];           //Convert.ToDateTime(drseason["StartDate"].ToString()).ToShortDateString();
                                NewPlantation.Rows[rowcount]["FirstHarvestDate" + "_" + drproduct["ProductId"]]         = drplantation["FirstHarvestDate"];         // (Convert.ToDateTime(drseason["StartDate"].ToString()).AddDays(100)).ToShortDateString();
                                NewPlantation.Rows[rowcount]["FirstHerbaga" + "_" + drproduct["ProductId"]]             = drplantation["FirstHerbaga"];             // "0";
                                NewPlantation.Rows[rowcount]["FirstDistillationDate" + "_" + drproduct["ProductId"]]    = drplantation["FirstDistillationDate"];    // (Convert.ToDateTime(drseason["StartDate"].ToString()).AddDays(101)).ToShortDateString();
                                NewPlantation.Rows[rowcount]["FirstDistillationUnitNO" + "_" + drproduct["ProductId"]]  = drplantation["FirstDistillationUnitNO"];  // "0";
                                NewPlantation.Rows[rowcount]["FirstProductQuantity" + "_" + drproduct["ProductId"]]     = drplantation["FirstProductQuantity"];     // "0";
                                NewPlantation.Rows[rowcount]["SecondHarvestDate" + "_" + drproduct["ProductId"]]        = drplantation["SecondHarvestDate"];        // (Convert.ToDateTime(drseason["StartDate"].ToString()).AddDays(145)).ToShortDateString(); ;
                                NewPlantation.Rows[rowcount]["SecondHerbaga" + "_" + drproduct["ProductId"]]            = drplantation["SecondHerbaga"];            // "0";
                                NewPlantation.Rows[rowcount]["SecondDistillationDate" + "_" + drproduct["ProductId"]]   = drplantation["SecondDistillationDate"];   // (Convert.ToDateTime(drseason["StartDate"].ToString()).AddDays(146)).ToShortDateString(); ;
                                NewPlantation.Rows[rowcount]["SecondDistillationUnitNO" + "_" + drproduct["ProductId"]] = drplantation["SecondDistillationUnitNO"]; // "0";
                                NewPlantation.Rows[rowcount]["SecondProductQuantity" + "_" + drproduct["ProductId"]]    = drplantation["SecondProductQuantity"];    // "0";
                                NewPlantation.Rows[rowcount]["TotalProductQuantity" + "_" + drproduct["ProductId"]]     = drplantation["TotalProductQuantity"];     // "0";
                            }
                        }
                    }
                    if (count == 0)
                    {
                        NewPlantation.Rows.Add(newdr);
                    }
                    rowcount += 1;
                }
                count += 1;
            }

            return(NewPlantation);
        }
Exemplo n.º 3
0
 public int GetProductByName(string productName)
 {
     return(CategoryProduct_DL.GetProductByName(productName));
 }
Exemplo n.º 4
0
 public int GetSeasonByName(string seasonName)
 {
     return(CategoryProduct_DL.GetSeasonByName(seasonName));
 }
Exemplo n.º 5
0
 public DataTable GetSeasonDetailsBasedonFarmerandYear(Guid farmerId, string Year)
 {
     return(CategoryProduct_DL.GetSeasonDetailsBasedonFarmerandYear(farmerId, Year));
 }
Exemplo n.º 6
0
 public DataTable GetProductNameByFarmerandSeason(int seasonId, Guid farmerId, int seasonYear)
 {
     return(CategoryProduct_DL.GetProductNameByFarmerandSeason(seasonId, farmerId, seasonYear));
 }
Exemplo n.º 7
0
 public DataTable GetSeasonDetails(string Year)
 {
     return(CategoryProduct_DL.GetSeasonDetails(Year));
 }
Exemplo n.º 8
0
 public DataTable SeasonDetails_FarmerSeasonProduct(Guid farmerId, int ProductID, int SeasonId, int seasonYear)
 {
     return(CategoryProduct_DL.SeasonDetails_FarmerSeasonProduct(farmerId, ProductID, SeasonId, seasonYear));
 }
Exemplo n.º 9
0
 public bool SeasonProduct_INSandUPDandDEL(int ProductID, int SeasonId, int typeOperation)
 {
     return(CategoryProduct_DL.SeasonProduct_INSandUPDandDEL(ProductID, SeasonId, typeOperation));
 }
Exemplo n.º 10
0
 public DataTable GetSeasonDetails(int seasonId)
 {
     return(CategoryProduct_DL.GetSeasonDetails(seasonId));
 }
Exemplo n.º 11
0
 public DataTable GetSeasonDetails()
 {
     return(CategoryProduct_DL.GetSeasonDetails());
 }
Exemplo n.º 12
0
 public int Season_INT_UPT(int SeasonID, string Seasonname, DateTime StartDate, DateTime EndDate, string createdby, string modifiedby, int typeOperation, int SeasonYear)
 {
     return(CategoryProduct_DL.Season_INT_UPT(SeasonID, Seasonname, StartDate, EndDate, createdby, modifiedby, typeOperation, SeasonYear));
 }
Exemplo n.º 13
0
 public bool Category_INT_UPT(int categoryID, string categoryname, string createdby, string modifiedby, int typeOperation)
 {
     return(CategoryProduct_DL.Category_INT_UPT(categoryID, categoryname, createdby, modifiedby, typeOperation));
 }