Ejemplo n.º 1
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);
        }
Ejemplo n.º 2
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;
            }
        }