public string insertReceiveOrderDetails(ReceiveOrdersFingerDetails drsi)
        {
            string Message = string.Empty;
            int result = 0;
            con.Open();
            SqlTransaction transaction;
            SqlCommand cmd = new SqlCommand("INSERT INTO [dbo].ReceiveOrdersFingerlingsDetails ([Quantity],[ReceiveOrderID],[ProductID],[IsSubmitted],[PostedToInventory]) VALUES (@Quantity,@ReceiveOrderID,@ProductID,@IsSubmitted,@PostedToInventory)", con);
            cmd.Parameters.AddWithValue("@Quantity", drsi.Quantity);
            //cmd.Parameters.AddWithValue("@UnitCost", drsi.UnitCost);
            cmd.Parameters.AddWithValue("@ReceiveOrderID", drsi.ReceiveOrderID);
            cmd.Parameters.AddWithValue("@ProductID", drsi.ProductID);

            cmd.Parameters.AddWithValue("@IsSubmitted", 1);

            cmd.Parameters.AddWithValue("@PostedToInventory", 1);
            transaction = con.BeginTransaction();
            cmd.Transaction = transaction;
            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);
                }
            }
            con.Close();
            //string query = "select top 1 ID from [DRSIForm] 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();
            //}
            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();
            }
        }