public CashOffice Insert(CashOffice ins)
        {
            //...Get User and Date Data...
            string              ModifiedDate = string.Format("{0:yyyy-MM-dd hh:mm:ss}", DateTime.Now);
            string              UserID       = HttpContext.Current.Session["Username"].ToString();
            string              strTrx       = "CashoffIns_" + UserID;
            DropDownRepository  ddrep        = new DropDownRepository();
            MoneyUnitRepository mRep         = new MoneyUnitRepository();
            decimal             moneyunit    = mRep.GetMoneyUnitValue(ins.MoneyUnitTypeID);
            string              cashstatus   = ddrep.GetCashOfficeStatus(ins.CashStatus);

            if (cashstatus == "Sealed")
            {
                ins.Amount = ins.Amount;
            }
            else if (cashstatus == "Opened")
            {
                ins.Amount = ins.Amount * moneyunit;
            }
            //...Database Connection...
            DataBaseConnection dbConn = new DataBaseConnection();
            SqlConnection      con    = dbConn.SqlConn();

            con.Open();

            //...Command Interface...
            SqlCommand     cmdI = con.CreateCommand();
            SqlTransaction trx;

            trx              = con.BeginTransaction(strTrx);
            cmdI.Connection  = con;
            cmdI.Transaction = trx;

            try
            {
                //...Insert Record...
                cmdI.CommandText = StoredProcedures.CashOfficeInsert;
                cmdI.CommandType = System.Data.CommandType.StoredProcedure;
                cmdI.Parameters.AddWithValue("@CashOfficeTypeID", ins.CashOfficeTypeID);
                cmdI.Parameters.AddWithValue("@MoneyUnitTypeID", ins.MoneyUnitTypeID);
                cmdI.Parameters.AddWithValue("@Amount", ins.Amount);
                cmdI.Parameters.AddWithValue("@CashStatus", ins.CashStatus);
                cmdI.Parameters.AddWithValue("@ModifiedBy", UserID);
                cmdI.Parameters.AddWithValue("@ModifiedDate", ModifiedDate);
                cmdI.Parameters.AddWithValue("@ActualDate", ins.ActualDate);
                cmdI.Parameters.AddWithValue("@Removed", 0);
                cmdI.Parameters.AddWithValue("@CompanyID", ins.CompanyID);


                //...Return new ID
                ins.CashOfficeID = (int)cmdI.ExecuteScalar();

                trx.Commit();
                cmdI.Connection.Close();
            }
            catch (SqlException ex)
            {
                if (trx != null)
                {
                    trx.Rollback();
                }
            }
            finally
            {
                //Check for close and respond accordingly
                if (con.State != ConnectionState.Closed)
                {
                    con.Close();
                }
                //Clean up
                con.Dispose();
                cmdI.Dispose();
                trx.Dispose();
            }
            return(ins);
        }
        public CashOffice Insert(CashOffice ins)
        {
            //...Get User and Date Data...
            string ModifiedDate = string.Format("{0:yyyy-MM-dd hh:mm:ss}", DateTime.Now);
            string UserID = HttpContext.Current.Session["Username"].ToString();
            string strTrx = "CashoffIns_" + UserID;
            DropDownRepository ddrep = new DropDownRepository();
            MoneyUnitRepository mRep = new MoneyUnitRepository();
            decimal moneyunit = mRep.GetMoneyUnitValue(ins.MoneyUnitTypeID);
            string cashstatus = ddrep.GetCashOfficeStatus(ins.CashStatus);
            if(cashstatus == "Sealed")
            {
                ins.Amount = ins.Amount;
            }
            else if (cashstatus == "Opened")
            {
                ins.Amount = ins.Amount * moneyunit;
            }
            //...Database Connection...
            DataBaseConnection dbConn = new DataBaseConnection();
            SqlConnection con = dbConn.SqlConn();
            con.Open();

            //...Command Interface...
            SqlCommand cmdI = con.CreateCommand();
            SqlTransaction trx;
            trx = con.BeginTransaction(strTrx);
            cmdI.Connection = con;
            cmdI.Transaction = trx;

            try
            {
                //...Insert Record...
                cmdI.CommandText = StoredProcedures.CashOfficeInsert;
                cmdI.CommandType = System.Data.CommandType.StoredProcedure;
                cmdI.Parameters.AddWithValue("@CashOfficeTypeID", ins.CashOfficeTypeID);
                cmdI.Parameters.AddWithValue("@MoneyUnitTypeID", ins.MoneyUnitTypeID);
                cmdI.Parameters.AddWithValue("@Amount", ins.Amount);
                cmdI.Parameters.AddWithValue("@CashStatus" , ins.CashStatus);
                cmdI.Parameters.AddWithValue("@ModifiedBy", UserID);
                cmdI.Parameters.AddWithValue("@ModifiedDate" , ModifiedDate);
                cmdI.Parameters.AddWithValue("@ActualDate", ins.ActualDate);
                cmdI.Parameters.AddWithValue("@Removed", 0);
                cmdI.Parameters.AddWithValue("@CompanyID", ins.CompanyID);

                //...Return new ID
                ins.CashOfficeID = (int)cmdI.ExecuteScalar();

                trx.Commit();
                cmdI.Connection.Close();
            }
            catch (SqlException ex)
            {
                if (trx != null) trx.Rollback();
            }
            finally
            {
                //Check for close and respond accordingly
                if (con.State != ConnectionState.Closed)
                {
                    con.Close();
                }
                //Clean up
                con.Dispose();
                cmdI.Dispose();
                trx.Dispose();
            }
            return ins;
        }