Пример #1
0
 public DataTable GetProductDetails(string Productvalue)
 {
     return(Product_DL.GetProductDetails(Productvalue));
 }
Пример #2
0
 public DataTable GetProductDetails(string FarmerID, string Year)
 {
     return(Product_DL.GetProductDetails(FarmerID, Year));
 }
Пример #3
0
 public DataTable GetProductDetails(int ProductID)
 {
     return(Product_DL.GetProductDetails(ProductID));
 }
Пример #4
0
 public DataTable GetProductDetails(string startDate, string endDate, string ProductID)
 {
     return(Product_DL.GetProductDetails(startDate, endDate, ProductID));
 }
Пример #5
0
 public DataTable GetProductDetails(int seasonID, int CategoryID)
 {
     return(Product_DL.GetProductDetails(seasonID, CategoryID));
 }
Пример #6
0
 public DataTable GetProductDetails()
 {
     return(Product_DL.GetProductDetails());
 }
        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);
        }