public string insertRR(ReceiveOrdersFinger drsi)
        {
            string Message = string.Empty;
            int result = 0;
            SqlTransaction transaction;

            con.Open();
            SqlCommand cmd = new SqlCommand("INSERT INTO [dbo].ReceiveOrdersFingerlings ([SupplierID],[CreatedById],[CreationDate],[IsCompleted],[IsSubmitted],[IsNew],[PurchaseOrderID],DateofShipment ,DateofArrival ,DateReceive ,TimeofShipment ,TimeofArrival ,TimeReceive ,ReoxygenationStart ,ReoxygenationEnd ,SalinityInsideTheBag ,TemperatureInsideTheBag ,TimeAfterReceiptFromAirport ,Mortality ,TimeofArrival1 ,TimeofStocking ,Mortality1 ,Deformed ,Injured ,Missing ) VALUES (@SupplierID,@CreatedById,getdate(),@IsCompleted,@IsSubmitted,@IsNew,@PurchaseOrderID,@DateofShipment ,@DateofArrival ,@DateReceive ,@TimeofShipment ,@TimeofArrival ,@TimeReceive ,@ReoxygenationStart ,@ReoxygenationEnd ,@SalinityInsideTheBag ,@TemperatureInsideTheBag ,@TimeAfterReceiptFromAirport ,@Mortality ,@TimeofArrival1 ,@TimeofStocking ,@Mortality1 ,@Deformed ,@Injured ,@Missing )", con);
            //cmd.CommandText = "InsertRR";
            cmd.Parameters.AddWithValue("@SupplierID", drsi.SupplierID);
            cmd.Parameters.AddWithValue("@CreatedById", drsi.CreatedById);
            //cmd.Parameters.AddWithValue("@ExpectedDate", drsi.ExpectedDate);
            //cmd.Parameters.AddWithValue("@PaymentAmount", drsi.PaymentAmount);
            cmd.Parameters.AddWithValue("@IsCompleted", 1);
            cmd.Parameters.AddWithValue("@IsSubmitted", 1);
            cmd.Parameters.AddWithValue("@IsNew", 1);
            cmd.Parameters.AddWithValue("@PurchaseOrderID", drsi.PurchaseOrderID);

            cmd.Parameters.AddWithValue("@DateofShipment", drsi.DateofShipment);
            cmd.Parameters.AddWithValue("@DateofArrival", drsi.DateofArrival);
            cmd.Parameters.AddWithValue("@DateReceive", drsi.DateReceive);
            cmd.Parameters.AddWithValue("@TimeofShipment ", drsi.TimeofShipment);
            cmd.Parameters.AddWithValue("@TimeofArrival", drsi.TimeofArrival);
            cmd.Parameters.AddWithValue("@TimeReceive", drsi.TimeReceive);
            cmd.Parameters.AddWithValue("@ReoxygenationStart", drsi.ReoxygenationStart);
            cmd.Parameters.AddWithValue("@ReoxygenationEnd", drsi.ReoxygenationEnd);
            cmd.Parameters.AddWithValue("@SalinityInsideTheBag", drsi.SalinityInsideTheBag);
            cmd.Parameters.AddWithValue("@TemperatureInsideTheBag", drsi.TemperatureInsideTheBag);
            cmd.Parameters.AddWithValue("@TimeAfterReceiptFromAirport", drsi.TimeAfterReceiptFromAirport);
            cmd.Parameters.AddWithValue("@Mortality", drsi.Mortality);
            cmd.Parameters.AddWithValue("@TimeofArrival1", drsi.TimeofArrival1);
            cmd.Parameters.AddWithValue("@TimeofStocking", drsi.TimeofStocking);
            cmd.Parameters.AddWithValue("@Mortality1", drsi.Mortality1);
            cmd.Parameters.AddWithValue("@Deformed", drsi.Deformed);
            cmd.Parameters.AddWithValue("@Injured", drsi.Injured);
            cmd.Parameters.AddWithValue("@Missing", drsi.Missing);

            transaction = con.BeginTransaction();
            cmd.Transaction = transaction;
            //cmd.Parameters.AddWithValue("@OrderBy", drsi.OrderBy);
            //cmd.Parameters.AddWithValue("@CheckBy", drsi.CheckBy != null ? drsi.CheckBy : string.Empty);
            try
            {
                result = cmd.ExecuteNonQuery();
                transaction.Commit();
            }
            catch (Exception ex)
            {
                try
                {
                    transaction.Rollback();
                }
                catch (Exception ex2)
                {
                    // This catch block will handle any errors that may have occurred
                    // on the server that would cause the rollback to fail, such as
                    // a closed connection.
                    Console.WriteLine("Rollback Exception Type: {0}", ex2.GetType());
                    Console.WriteLine("  Message: {0}", ex2.Message);
                }
            }

            string query = "select top 1 ID from [ReceiveOrdersFingerlings] order by id desc";
            DataTable dt = new DataTable("Customer");
            dt.Clear();
            dt = DataAccess.DBAdapter.GetRecordSet(query);

            if (dt.Rows.Count > 0)
            {
                Message = dt.Rows[0]["ID"].ToString();
            }
            con.Close();
            return Message;
        }
        protected void btnSave1_Click(object sender, EventArgs e)
        {
            dtgridList = (DataTable)ViewState["dtgridList"];
            dtgridList1 = (DataTable)ViewState["dtgridList1"];
            string users = Session["id"].ToString();
            decimal totalamt = 0;
            try
            {

                FrameWork.ReceiveOrdersFinger RRO = new FrameWork.ReceiveOrdersFinger();
                FrameWork.ReceiveOrdersFingerDetails PROsub = new ReceiveOrdersFingerDetails();
                FrameWork.ReceiveOrdersFingerDetails2 PROsub2 = new ReceiveOrdersFingerDetails2();
                busReceivedOrderFingerLings busPRO = new busReceivedOrderFingerLings();

                RRO.SupplierID = int.Parse(this.drpSupplier.SelectedValue);
                RRO.CreatedById = int.Parse(users);
                RRO.PurchaseOrderID = int.Parse(this.txtPro.Text);
                RRO.DateofShipment =DateTime.Parse (this.txtDateShipment.Text);
                RRO.DateofArrival = DateTime.Parse(this.txtDateArrival.Text);
                RRO.DateReceive = DateTime.Parse(this.txtDateReceive.Text);
                RRO.TimeofShipment = DateTime.Parse(this.txtTimeShipment.Text).TimeOfDay;
                RRO.TimeofArrival = DateTime.Parse(this.txtTimeArrival.Text).TimeOfDay;
                RRO.TimeReceive = DateTime.Parse(this.txtTimeReceive.Text).TimeOfDay;
                RRO.ReoxygenationStart = DateTime.Parse(this.txtReoxygen.Text).TimeOfDay;
                RRO.ReoxygenationEnd = DateTime.Parse(this.txtFinish.Text).TimeOfDay;
                RRO.SalinityInsideTheBag =int.Parse(this.txtSalinity.Text);
                RRO.TemperatureInsideTheBag = int.Parse(this.txtTemp.Text);
                RRO.TimeAfterReceiptFromAirport = DateTime.Parse(this.txtTimeReceiveAirport.Text).TimeOfDay;
                RRO.Mortality = int.Parse(this.txtMortality.Text);
                RRO.TimeofArrival1 = DateTime.Parse(this.txtTimeArrival1.Text).TimeOfDay;
                RRO.TimeofStocking = DateTime.Parse(this.txtTimeStocking.Text).TimeOfDay;
                RRO.Mortality1 = int.Parse(this.txtMortality1.Text);
                RRO.Deformed = int.Parse(this.txtDeformed.Text);
                RRO.Injured = int.Parse(this.txtInjured.Text);
                RRO.Missing = int.Parse(this.txtMissing.Text);

                string x = busPRO.insertRR(RRO);
                foreach (DataRow dr in dtgridList.Rows)
                {
                    PROsub.ReceiveOrderID = int.Parse(x);
                    PROsub.Quantity = Single.Parse(dr["Quantity"].ToString());

                    PROsub.ProductID = int.Parse(dr["ProductID"].ToString());

                    busPRO.insertReceiveOrderDetails(PROsub);
                }
                foreach (DataRow dr1 in dtgridList1.Rows)
                {
                    PROsub2.ReceiveOrderID = int.Parse(x);
                    PROsub2.ModuleNum = int.Parse(dr1["ModuleNum"].ToString());
                    PROsub2.CageNum = int.Parse(dr1["CageNum"].ToString());
                    PROsub2.Salinity = int.Parse(dr1["Salinity"].ToString());
                    PROsub2.Temp = int.Parse(dr1["Temp"].ToString());
                    busPRO.insertReceiveOrderDetails2(PROsub2);
                }
            }
            catch (Exception ex)
            {

            }
            finally
            {
                this.txtQuantity.Text = string.Empty;
                this.txtUOM.Text = string.Empty;
                this.drpProduct.SelectedValue = "0";
                this.lblDescription.Text = string.Empty;
                //this.txtUnitPrice.Text = string.Empty;
                this.drpSupplier.SelectedValue = "0";
                // this.txtTerms.Text = string.Empty;
                DataTable ds = new DataTable();
                ds = null;
                this.grdList.DataSource = ds;
                grdList.DataBind();
            }
        }