예제 #1
0
    public void SaveMonthOpenClose(MonthOpenCloseDB objDB, SqlTransaction objTrans)
    {
        DataAccessLayer objDataLayer = new DataAccessLayer();
        SqlCommand objCmd = new SqlCommand();
        try
        {
            objCmd.CommandText = "usp_SaveMonthOpenClose";
            objCmd.CommandType = CommandType.StoredProcedure;
            objCmd.Parameters.AddWithValue("@MonthID", objDB.MonthID);
            objCmd.Parameters.AddWithValue("@YearID", objDB.YearID);
            objCmd.Parameters.AddWithValue("@Status", objDB.Status);
            objCmd.Parameters.AddWithValue("@id", SqlDbType.Int);
            objCmd.Parameters["@id"].Direction = ParameterDirection.Output;

            objCmd.Transaction = objTrans;
            objCmd.Connection = objTrans.Connection;
            objDataLayer.Command = objCmd;
            objDataLayer.ExecQuery();

        }
        catch (Exception ex)
        {

            throw ex;
        }
    }
예제 #2
0
    public void SaveMonthOpenClose(MonthOpenCloseUI objUI)
    {
        bool flagTransation = true;

        MonthOpenCloseDB objDB = new MonthOpenCloseDB();
        objDB.MonthID = objUI.MonthID;
        objDB.YearID = objUI.YearID;
        objDB.Status = objUI.Status;

        DataAccessLayer objDataAccess = new DataAccessLayer();
        SqlTransaction objTrans = null;
        try
        {

            if (objTrans == null)
            {
                flagTransation = false;
                objDataAccess.GetConnection.Open();
                SqlTransaction objTransaction = objDataAccess.GetConnection.BeginTransaction();
                objTrans = objTransaction;
            }
            MonthOpenCloseManager objManager = new MonthOpenCloseManager();
            objManager.SaveMonthOpenClose(objDB, objTrans);
            if (!flagTransation)
                objTrans.Commit();

        }
        catch (Exception ex)
        {
            if (!flagTransation)
                objTrans.Rollback();
            throw ex;
        }
        finally
        {
            objDataAccess.GetConnection.Close();
        }
    }