Ejemplo n.º 1
0
        protected void LoadBirdPrice()
        {
            int Day   = int.Parse(ddlDays.SelectedValue.Trim());
            int Month = int.Parse(ddlMonth.SelectedValue.Trim());
            int Year  = int.Parse(ddlYear.SelectedValue.Trim());
            //string SDate = (Month + "/" + Day + "/" + Year).ToString();
            string   SDate = (Year + "-" + Month + "-" + Day).ToString();
            DateTime DDate = Convert.ToDateTime(SDate);

            BusinessLayer.SMS.BirdPrice ObjBirdPrice = new BusinessLayer.SMS.BirdPrice();
            DataTable dt = ObjBirdPrice.GetAll(DDate);

            if (dt != null)
            {
                dgvBirdPrice.DataSource = dt;
                dgvBirdPrice.DataBind();
            }
            else
            {
            }

            BusinessLayer.SMS.EggPrice ObjEggPrice = new BusinessLayer.SMS.EggPrice();
            Entity.SMS.EggPrice        EggPrice    = new Entity.SMS.EggPrice();
            EggPrice = ObjEggPrice.GetAllById(DDate);

            if (EggPrice != null)
            {
                txtNECCEggRate.Text  = EggPrice.NECCPrice.ToString();
                txtbelowWt.Text      = EggPrice.belowWt.ToString();
                txtoverWt.Text       = EggPrice.overWt.ToString();
                txtbelowAddRate.Text = EggPrice.belowAddRate.ToString();
                txtoverAddRate.Text  = EggPrice.overAddRate.ToString();
            }
        }
        protected String BStrMssg()
        {
            int    Day             = int.Parse(ddlDays.SelectedValue.Trim());
            int    Month           = int.Parse(ddlMonth.SelectedValue.Trim());
            int    Year            = int.Parse(ddlYear.SelectedValue.Trim());
            string districtDetails = "";
            //string SDate = (Month + "/" + Day + "/" + Year).ToString();
            string   SDate = (Year + "-" + Month + "-" + Day).ToString();
            DateTime DDate = Convert.ToDateTime(SDate);

            StringBuilder StrMssg = new StringBuilder();
            string        Str1    = "WBPF Broiler suggested rate for " + DDate.ToString("dd/MM/yyyy") + "\n";

            StrMssg.Append(Str1);

            BusinessLayer.SMS.BirdPrice ObjBirdPrice = new BusinessLayer.SMS.BirdPrice();
            DataTable dt = ObjBirdPrice.GetAll(DDate);

            if (Mssg == "")
            {
                foreach (DataRow dr in dt.Rows)
                {
                    districtDetails = dr["DistrictName"].ToString() + "-" + dr["FarmRate"].ToString() + "/" + dr["RetailerRate"].ToString() + "/" + dr["BroilerRate"].ToString() + "/" + dr["DressedRate"].ToString() + "\n";
                    StrMssg.Append(districtDetails);
                }
                BusinessLayer.SMS.EggPrice ObjEggPrice = new BusinessLayer.SMS.EggPrice();
                Entity.SMS.EggPrice        Eggprice    = new Entity.SMS.EggPrice();
                Eggprice = ObjEggPrice.GetAllById(DDate);


                //string Str2 = "Bird weight below" + Eggprice.belowWt.ToString() + "kg.=Dist.rate plus Rs." + Eggprice.belowAddRate.ToString() + ".NECC egg rate-" + Eggprice.NECCPrice.ToString();
                string Str2 = "Bird weight below " + Eggprice.belowWt.ToString() + "kg.=Dist.rate plus Rs." + Eggprice.belowAddRate.ToString() + ". NECC egg rate " + Eggprice.NECCPrice.ToString();
                StrMssg.Append(Str2);

                txtMssg.Text = StrMssg.ToString();
            }
            else
            {
                Mssg = txtMssg.Text;
            }

            return(Mssg);
        }
Ejemplo n.º 3
0
        protected void LoadMonthlyPrice()
        {
            int Month     = int.Parse(ddlMonth.SelectedValue.Trim());
            int Year      = int.Parse(ddlYear.SelectedValue.Trim());
            int DaysCount = DateTime.DaysInMonth(Year, Month);

            BusinessLayer.SMS.district Objdistrict = new BusinessLayer.SMS.district();
            DataTable dt = Objdistrict.GetAll();

            int RowCount = dt.Rows.Count;

            DataTable dtMonthly = new DataTable();

            dtMonthly.Columns.Add("DistName", typeof(string));
            for (int k = 1; k <= 31; k++)
            {
                dtMonthly.Columns.Add(k.ToString(), typeof(string));
            }

            dtMonthly.Columns.Add("Month", typeof(int));
            dtMonthly.Columns.Add("Avg", typeof(string));
            dtMonthly.Columns.Add("NeccPrice", typeof(string));


            foreach (DataRow drDist in dt.Rows)
            {
                string str;

                int DistrictId = Convert.ToInt32(drDist["DistrictId"].ToString());
                BusinessLayer.SMS.BirdPrice ObjBirdPrice = new BusinessLayer.SMS.BirdPrice();
                DataTable dt1 = ObjBirdPrice.GetAllMonthly(Month, Year, DistrictId);

                Count1++;

                DataRow dr = dtMonthly.NewRow();

                if (dt1.Rows.Count != 0 && dt != null)
                {
                    int    TotalFramRate = 0, TotalRetailerRate = 0, TotalDressedRate = 0, TotalBroilerRate = 0;
                    double AvgFramRate, AvgRetailerRate, AvgDressedRate, AvgBroilerRate;

                    int Count = 0;
                    int j = 0, K = 0;



                    dr["DistName"] = str = (dt1.Rows[Count]["DistrictName"].ToString().Length == 0) ? "--" : dt1.Rows[Count]["DistrictName"].ToString();



                    foreach (DataRow dr1 in dt1.Rows)
                    {
                        DateTime Date = Convert.ToDateTime(dr1["Date"].ToString());
                        int      Day  = int.Parse(Date.Day.ToString());

                        while (Day > Count)
                        {
                            if (Day == Count + 1)
                            {
                                dr[Count + 1]     = (dt1.Rows[j]["FarmRate"].ToString() + "/" + dt1.Rows[j]["RetailerRate"].ToString() + "/" + dt1.Rows[j]["BroilerRate"].ToString() + "/" + dt1.Rows[j]["DressedRate"].ToString());
                                TotalFramRate     = TotalFramRate + Convert.ToInt32(dt1.Rows[j]["FarmRate"].ToString());
                                TotalRetailerRate = TotalRetailerRate + Convert.ToInt32(dt1.Rows[j]["RetailerRate"].ToString());
                                TotalDressedRate  = TotalDressedRate + Convert.ToInt32(dt1.Rows[j]["DressedRate"].ToString());
                                TotalBroilerRate  = TotalBroilerRate + Convert.ToInt32(dt1.Rows[j]["BroilerRate"].ToString());
                                Count++;
                                j++;
                                K = K + 1;
                            }
                            else
                            {
                                for (int i = Count + 1; i < Day; i++)
                                {
                                    dr[Count + 1] = "--" + "\n" + "--";
                                    Count++;
                                }
                            }
                        }
                    }
                    AvgFramRate     = TotalFramRate / K;
                    AvgRetailerRate = TotalRetailerRate / K;
                    AvgDressedRate  = TotalDressedRate / K;
                    AvgBroilerRate  = TotalBroilerRate / K;
                    dr["Avg"]       = AvgFramRate.ToString() + "/" + AvgRetailerRate.ToString() + "/" + AvgBroilerRate.ToString() + "/" + AvgDressedRate.ToString();

                    while (Count < 31)
                    {
                        dr[Count + 1] = "--" + "\n" + "--";
                        Count++;
                    }
                    dr["Month"] = Month;



                    dtMonthly.Rows.Add(dr);
                    dtMonthly.AcceptChanges();
                }
            }

            if (dtMonthly.Rows.Count != 0)
            {
                dgvMonthlyPrice.Visible = true;
                lblmssg.Visible         = false;
                DataRow dr2 = dtMonthly.NewRow();
                BusinessLayer.SMS.EggPrice ObjEggprice = new BusinessLayer.SMS.EggPrice();
                DataTable dt2 = ObjEggprice.GetEggPrice(Month, Year);
                dr2["DistName"] = "NECC Egg Rate";
                int j = 1, k = 0;
                int count = dt2.Rows.Count;
                for (j = 1; j <= 31; j++)
                {
                    //if (j == 31)
                    //    k = k - 1;

                    int c = (k < count ? Convert.ToDateTime(dt2.Rows[k]["Date"]).Day : 0);
                    if (c == j)
                    {
                        dr2[j] = dt2.Rows[k]["NECCPrice"].ToString();
                        k++;
                    }
                    else
                    {
                        dr2[j] = "--";
                    }
                }

                dtMonthly.Rows.Add(dr2);

                ViewState["RowCount"]      = dtMonthly.Rows.Count;
                dgvMonthlyPrice.DataSource = dtMonthly;
                dgvMonthlyPrice.DataBind();
            }
            else
            {
                dgvMonthlyPrice.Visible = false;
                lblmssg.Visible         = true;
            }
        }
Ejemplo n.º 4
0
        protected void SaveBirdRate()
        {
            int Day   = int.Parse(ddlDays.SelectedValue.Trim());
            int Month = int.Parse(ddlMonth.SelectedValue.Trim());
            int Year  = int.Parse(ddlYear.SelectedValue.Trim());
            //string SDate = Month + "/" + Day + "/" + Year;
            string SDate = Year + "-" + Month + "-" + Day;

            DateTime DDate = Convert.ToDateTime(SDate);

            DataTable DtBirdPrice = new DataTable();

            DtBirdPrice.Columns.Add("DistrictId", typeof(int));
            DtBirdPrice.Columns.Add("FarmRate", typeof(int));
            DtBirdPrice.Columns.Add("RetailerRate", typeof(int));
            DtBirdPrice.Columns.Add("DressedRate", typeof(int));
            DtBirdPrice.Columns.Add("BroilerRate", typeof(int));
            DtBirdPrice.Columns.Add("Date", typeof(DateTime));

            DataRow dr;
            TextBox Txt;

            foreach (GridViewRow DGR in dgvBirdPrice.Rows)
            {
                dr = DtBirdPrice.NewRow();
                dr["DistrictId"] = int.Parse(dgvBirdPrice.DataKeys[DGR.RowIndex].Value.ToString());

                Txt            = (TextBox)DGR.FindControl("txtFarmRate");
                dr["FarmRate"] = (Txt.Text.Trim().Length == 0) ? 0 : int.Parse(Txt.Text.Trim());

                Txt = (TextBox)DGR.FindControl("txtRetailerRate");
                dr["RetailerRate"] = (Txt.Text.Trim().Length == 0) ? 0 : int.Parse(Txt.Text.Trim());

                Txt = (TextBox)DGR.FindControl("txtDressedRate");
                dr["DressedRate"] = (Txt.Text.Trim().Length == 0) ? 0 : int.Parse(Txt.Text.Trim());

                Txt = (TextBox)DGR.FindControl("txtBroilerRate");
                dr["BroilerRate"] = (Txt.Text.Trim().Length == 0) ? 0 : int.Parse(Txt.Text.Trim());

                dr["Date"] = DDate;

                DtBirdPrice.Rows.Add(dr);
                DtBirdPrice.AcceptChanges();
            }

            BusinessLayer.SMS.BirdPrice ObjBirdPrice = new BusinessLayer.SMS.BirdPrice();

            ObjBirdPrice.Save(DDate, DtBirdPrice);


            BusinessLayer.SMS.EggPrice ObjEggPrice = new BusinessLayer.SMS.EggPrice();
            Entity.SMS.EggPrice        Eggprice    = new Entity.SMS.EggPrice();

            Eggprice.date         = DDate;
            Eggprice.NECCPrice    = decimal.Parse(txtNECCEggRate.Text.Trim());
            Eggprice.belowWt      = decimal.Parse(txtbelowWt.Text.Trim());
            Eggprice.overWt       = decimal.Parse(txtoverWt.Text.Trim());
            Eggprice.belowAddRate = decimal.Parse(txtbelowAddRate.Text.Trim());
            Eggprice.overAddRate  = decimal.Parse(txtoverAddRate.Text.Trim());

            ObjEggPrice.Save(Eggprice);
        }