コード例 #1
0
        protected String BStrMssg()
        {
            int    Day             = int.Parse(ddlDay.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" + "Farmer,PTR,Retailer(Whole Bird/Dressed Bird)" + "\n";

            StrMssg.Append(Str1);

            BusinessLayer.Common.BirdPrice ObjBirdPrice = new BusinessLayer.Common.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.Common.EggPrice ObjEggPrice = new BusinessLayer.Common.EggPrice();
                Entity.Common.EggPrice        Eggprice    = new Entity.Common.EggPrice();
                Eggprice = ObjEggPrice.GetAllById(DDate);


                // string Str2 = "Bird weight below " + Eggprice.belowWt.ToString() + "kg.=Dist.rate plus Rs." + Eggprice.belowAddRate.ToString() + ".Bird weight upto(1.1kg-1.3kg)=Dist.rate plus Rs." + Eggprice.overAddRate.ToString() + ".NECC Egg Rate:SB-" + Eggprice.NECCPrice.ToString() + ",NAD-" + Eggprice.NECCPrice2.ToString() + ",NB-" + Eggprice.NECCPrice3.ToString();

                string Str2 = "Bird weight below " + Eggprice.belowWt.ToString() + "kg.=Dist.rate plus Rs." + Eggprice.belowAddRate.ToString() + ".NECC WEST BENGAL Egg Rate of " + DDate.ToString("dd/MM/yyyy") + " Rs. " + Eggprice.NECCPrice.ToString();

                // Bird weight below 1.2kg.= Dist.rate plus Rs.20.00.NECC WEST BENGAL Egg Rate of 09.03.2021 Rs.4.53



                StrMssg.Append(Str2);

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

            return(Mssg);
        }
コード例 #2
0
        protected void LoadBirdPrice()
        {
            int Day   = int.Parse(ddlDay.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.Common.BirdPrice ObjBirdPrice = new BusinessLayer.Common.BirdPrice();
            DataTable dt = ObjBirdPrice.GetAll(DDate);

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

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

            if (EggPrice != null)
            {
                txtNECCEggRate.Text  = EggPrice.NECCPrice.ToString();
                txtNECCEggRate2.Text = EggPrice.NECCPrice2.ToString();
                txtNECCEggRate3.Text = EggPrice.NECCPrice3.ToString();
                txtbelowWt.Text      = EggPrice.belowWt.ToString();
                txtoverWt.Text       = EggPrice.overWt.ToString();
                txtbelowAddRate.Text = EggPrice.belowAddRate.ToString();
                txtoverAddRate.Text  = EggPrice.overAddRate.ToString();
            }
        }
        protected void LoadMonthlyPrice()
        {
            int Month     = int.Parse(ddlMonth.SelectedValue.Trim());
            int Year      = int.Parse(ddlYear.SelectedValue.Trim());
            int DaysCount = DateTime.DaysInMonth(Year, Month);

            BusinessLayer.Common.District Objdistrict = new BusinessLayer.Common.District();
            DataTable dt = Objdistrict.SMSDistrictGetAll();

            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.Common.BirdPrice ObjBirdPrice = new BusinessLayer.Common.BirdPrice();
                DataTable dt1       = ObjBirdPrice.GetAllMonthly(Month, Year, DistrictId);
                DateTime  TodayDate = DateTime.Now;
                int       monthNo   = TodayDate.Month;

                //Remove today rate

                if (monthNo == Month)
                {
                    int Maxrow = dt1.Rows.Count - 1;
                    dt1.Rows.RemoveAt(Maxrow);
                    dt1.AcceptChanges();
                }
                //DateTime LocalDate = DateTime.Now.AddHours(10);

                //if (dt1 != null && dt1.Rows.Count > 0)
                //{
                //    dt1 = dt1.AsEnumerable().Where(r =>
                //    !(
                //        Convert.ToDateTime(r["date"]).Day == LocalDate.Day
                //        && Convert.ToDateTime(r["date"]).Month == LocalDate.Month
                //        && Convert.ToDateTime(r["date"]).Year == LocalDate.Month)).CopyToDataTable();
                //}

                //if (dt1 != null && dt1.Rows.Count > 0)
                //{
                //    dt1 = dt1.AsEnumerable().Where(r =>
                //    !(
                //        Convert.ToDateTime(r["date"]).Day == DateTime.Now.Day
                //        && Convert.ToDateTime(r["date"]).Month == DateTime.Now.Month
                //        && Convert.ToDateTime(r["date"]).Year == DateTime.Now.Year)).CopyToDataTable();
                //}

                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;
                DataRow dr2 = dtMonthly.NewRow();
                BusinessLayer.Common.EggPrice ObjEggprice = new BusinessLayer.Common.EggPrice();
                DataTable dt2 = ObjEggprice.GetEggPrice(Month, Year);

                DateTime TodayDate = DateTime.Now;
                int      monthNo   = TodayDate.Month;

                //Remove today bird price
                if (monthNo == Month)
                {
                    int Maxrow = dt2.Rows.Count - 1;
                    dt2.Rows.RemoveAt(Maxrow);
                    dt2.AcceptChanges();
                }

                //DateTime LocalDate = DateTime.Now.AddHours(10);

                //if (dt2 != null && dt2.Rows.Count > 0)
                //{
                //    dt2 = dt2.AsEnumerable().Where(r =>
                //    !(
                //        Convert.ToDateTime(r["date"]).Day == LocalDate.Day
                //        && Convert.ToDateTime(r["date"]).Month == LocalDate.Month
                //        && Convert.ToDateTime(r["date"]).Year == LocalDate.Month)).CopyToDataTable();
                //}

                //if (dt2 != null && dt2.Rows.Count > 0)
                //{
                //    dt2 = dt2.AsEnumerable().Where(r =>
                //    !(
                //        Convert.ToDateTime(r["date"]).Day == DateTime.Now.Day
                //        && Convert.ToDateTime(r["date"]).Month == DateTime.Now.Month
                //        && Convert.ToDateTime(r["date"]).Year == DateTime.Now.Year)).CopyToDataTable();
                //}

                dr2["DistName"] = "NECC Egg Rate";
                int j = 1;
                foreach (DataRow DrNecc in dt2.Rows)
                {
                    dr2[j] = DrNecc["NECCPrice"].ToString().Length == 0 ? "--" : DrNecc["NECCPrice"].ToString();
                    j++;
                }
                Decimal AvgNECCPrice = Convert.ToDecimal(dt2.Compute("AVG([NECCPrice])", ""));

                dr2["Avg"] = AvgNECCPrice.ToString("0.00");

                dtMonthly.Rows.Add(dr2);


                ViewState["RowCount"]      = dtMonthly.Rows.Count;
                dgvMonthlyPrice.DataSource = dtMonthly;
                dgvMonthlyPrice.DataBind();
            }
            else
            {
                dgvMonthlyPrice.Visible = false;
            }
        }
コード例 #4
0
        protected void SaveBirdRate()
        {
            try
            {
                int Day   = int.Parse(ddlDay.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.Common.BirdPrice ObjBirdPrice = new BusinessLayer.Common.BirdPrice();

                ObjBirdPrice.Save(DDate, DtBirdPrice);


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

                Eggprice.date         = DDate;
                Eggprice.NECCPrice    = decimal.Parse(txtNECCEggRate.Text.Trim());
                Eggprice.NECCPrice2   = decimal.Parse(txtNECCEggRate2.Text.Trim());
                Eggprice.NECCPrice3   = decimal.Parse(txtNECCEggRate3.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);

                Message.IsSuccess = true;
                Message.Text      = "BirdPrice Saved Successfully";
            }
            catch
            {
                Message.IsSuccess = false;
                Message.Text      = "Something went wrong!!! Please try again...";
            }
            finally
            {
                Message.Show = true;
            }
        }