示例#1
0
        public HttpResponseMessage Api_Sport_Category_Search( )
        {
            SportModels.ResponseModel RM = new SportModels.ResponseModel();
            SportModels.CategoryModel CM = new SportModels.CategoryModel();
            try
            {
                // ?categoryName={CategoryName}&createdDate={CreatedDate}
                var varUrlKeyValues = ControllerContext.Request.GetQueryNameValuePairs();

                // lay cac value can thiet tu queryString
                CM.CategoryName = varUrlKeyValues.LastOrDefault(x => x.Key == "categoryName").Value;
                CM.CreatedDate  = Convert.ToDateTime(varUrlKeyValues.LastOrDefault(x => x.Key == "createdDate").Value);

                // 1. get data
                RM = CSport.Api_Sport_Category_Search_BLL(CM);

                // 2. return response (code 200)
                return(CreateJsonResponse(RM));
            }
            catch (Exception ex)
            {
                // log error
                CLog.LogError(CBase.GetDeepCaller(), CBase.GetDetailError(ex));
                // return error code
                return(Request.CreateResponse(HttpStatusCode.InternalServerError));
            }
        }
示例#2
0
        /// <summary>
        /// Thuc hien 1 store procedure (co tham so) tra ve 1 DataReader
        /// Input:
        ///       1. spName: ten store
        ///       2. myParamArray() : danh sach cac tham so
        /// Output: DataReader
        /// </summary>
        /// <param name="SPname">sp_SELECT</param>
        /// <returns></returns>
        public SqlDataReader GetDataReaderFromSP(string SPname)
        {
            if ((_OpenConnection() == false))           // Open Connection
            {
                return(null);
            }

            m_Command.Connection  = m_Connection;
            m_Command.CommandText = SPname;
            m_Command.CommandType = CommandType.StoredProcedure;
            try
            {
                CLog.LogSQL(CBase.GetDeepCaller(), SPname + this.GetParamInfo());      // log SQL

                DateTime dtBegin = DateTime.Now;                                       // duration
                m_DataReader       = m_Command.ExecuteReader();
                this.m_dblDuration = DateTime.Now.Subtract(dtBegin).TotalMilliseconds; // duration
                m_Command.Parameters.Clear();
                return(m_DataReader);
            }
            catch (Exception ex)
            {
                CLog.LogError(CBase.GetDeepCaller(), CBase.GetDetailError(ex));
                return(null);
            }
            finally
            {
                //_CloseConnection(); // _CloseConnection thi error, phai goi CloseConnection tu ben ngoai (Caller)
            }
        }
示例#3
0
        /// <summary>
        /// Thuc hien 1 câu lệnh sql tra ve 1 DataReader
        /// Input:
        ///       1. câu lệnh sql
        /// Output: DataReader
        /// </summary>
        /// <param name="SQL">select * from tbl_test</param>
        /// <returns></returns>
        public SqlDataReader GetDataReaderFromQuery(string myQuery)
        {
            if ((_OpenConnection() == false))           // Open Connection
            {
                return(null);
            }

            m_Command.Connection  = m_Connection;
            m_Command.CommandText = myQuery;
            m_Command.CommandType = CommandType.Text;
            try
            {
                CLog.LogSQL(CBase.GetDeepCaller(), myQuery);                           // log SQL

                DateTime dtBegin = DateTime.Now;                                       // duration
                m_DataReader       = m_Command.ExecuteReader();
                this.m_dblDuration = DateTime.Now.Subtract(dtBegin).TotalMilliseconds; // duration
                return(m_DataReader);
            }
            catch (Exception ex)
            {
                CLog.LogError(CBase.GetDeepCaller(), CBase.GetDetailError(ex));
                return(null);
            }
            finally
            {
                //_CloseConnection(); // _CloseConnection thi error, phai goi CloseConnection tu ben ngoai (Caller)
            }
        }
示例#4
0
        /// <summary>
        /// Thuc hien 1 cau query tra ve 1 dataset
        /// Input:
        ///         1. Ten store procedure
        /// Output: dataset
        /// </summary>
        /// <returns></returns>
        public DataSet GetDatasetFromSP(string SPname)
        {
            DataSet functionReturnValue = null;

            if ((_OpenConnection() == false))           // Open Connection
            {
                return(null);
            }
            DataSet ds = new DataSet();

            try
            {
                CLog.LogSQL(CBase.GetDeepCaller(), SPname + this.GetParamInfo());    // log SQL

                m_Command.Connection  = m_Connection;
                m_Command.CommandText = SPname;
                m_Command.CommandType = CommandType.StoredProcedure;
                DateTime dtBegin = DateTime.Now; // duration
                m_DataAdapter = new SqlDataAdapter(m_Command);
                m_DataAdapter.Fill(ds);
                this.m_dblDuration = DateTime.Now.Subtract(dtBegin).TotalMilliseconds; // duration
                m_Command.Parameters.Clear();
                functionReturnValue = ds;
            }
            catch (Exception ex)
            {
                functionReturnValue = null;
                CLog.LogError(CBase.GetDeepCaller(), CBase.GetDetailError(ex));
            }
            finally
            {
                _CloseConnection();     // Close Connection
            }
            return(functionReturnValue);
        }
示例#5
0
        //===================================== Delete Category =====================================//
        public static SportModels.DALOutput Api_Sport_Category_Delete_DAL(SportModels.CategoryModel CM)
        {
            DataSet ds = new DataSet();

            try
            {
                SqlParameter[] arrParams = new SqlParameter[1];

                // input params
                arrParams[0]           = new SqlParameter("categoryID", SqlDbType.Int);
                arrParams[0].Direction = ParameterDirection.Input;
                arrParams[0].Value     = CM.CategoryID;

                // exec
                ds = SqlHelper.ExecuteDataset(CConfigDS.CONNECTION_STRING_SQL_SPORT_SHOP, CommandType.StoredProcedure, CConfigDS.SPORT_SHOP_SQL_SP_CATEGORY_DELETE, arrParams);

                // return (neu sp ko tra error code,msg thi tu gan default)
                return(new SportModels.DALOutput()
                {
                    ErrorCode = CConfigDS.RESPONSE_CODE_SUCCESS, ErrorMessage = CConfigDS.RESPONSE_MSG_SUCCESS, SqlData = ds
                });
            }
            catch (Exception ex)
            {
                // log error
                CLog.LogError(CBase.GetDeepCaller(), CBase.GetDetailError(ex));
                // error => return null
                return(new SportModels.DALOutput()
                {
                    ErrorCode = CBase.GetLayerErrorCode(CBase.LAYER.DAL), ErrorMessage = ex.Message, SqlData = null
                });
            }
        }
        public JsonResult DeleteGroupMenu(string ID)
        {
            string result, resultC;

            try
            {
                DataSet ds     = new DataSet();
                int     iID    = string.IsNullOrEmpty(ID) ? 0 : Int32.Parse(ID.ToString());
                int     UserID = Session[CConfig.SESSION_USERID].ToString() == "" ? 1 : Convert.ToInt32(Session[CConfig.SESSION_USERID]);

                ds = data.DeleteGroupMenuRel(iID, UserID);

                if (ds.Tables[0].Rows.Count > 0)
                {
                    result  = ds.Tables[0].Rows[0][0].ToString();
                    resultC = ds.Tables[0].Rows[0][1].ToString();
                }
                else
                {
                    result  = "Error: Xóa Menu không thành công";
                    resultC = "-1";
                }
            }
            catch (Exception ex)
            {
                result  = "Error: Không thêm được menu vào group";
                resultC = "";
                CLog.LogError(CBase.GetDeepCaller(), CBase.GetDetailError(ex));
            }

            return(Json(new { mess = result, code = resultC }, JsonRequestBehavior.AllowGet));
        }
        /// <summary>
        /// get set room
        /// </summary>
        /// <param name="BookingCode"></param>
        /// <returns></returns>
        public JsonResult GetRoomForReservationRoom(string BookingCode)
        {
            List <string> json = new List <string>();
            DataSet       ds   = new DataSet();

            try
            {
                UserID    = Session[CConfig.SESSION_USERID] == null ? 1 : Convert.ToInt32(Session[CConfig.SESSION_USERID]);
                HotelCode = Session[CConfig.SESSION_HOTELCODE].ToString();
                if (HotelCode == null)
                {
                    Response.Redirect("Receptionist/BookingList");
                }
                json = data.GetReservationRoom_Detail(BookingCode, HotelCode, UserID);
                ////ds = data.GetReservationRoom_Detail( BookingCode, HotelCode, UserID);
                ////Thông tin đặt phòng
                //ViewData["BookingInfo"] = json[0];
                //// thong tin phong
                //ViewData["SetRoom"] = json[1];
                ////Thông tin khách hàng
                //ViewData["CustomerInfo"] = json[2];
            }
            catch (Exception ex)
            {
                CLog.LogError(CBase.GetDeepCaller(), CBase.GetDetailError(ex));
            }
            return(Json(new { mess = json }, JsonRequestBehavior.AllowGet));
        }
示例#8
0
        //===============================================================================================================

        #region Execute
        /// <summary>
        /// ExecuteQuery
        /// Thuc hien 1 cau lenh Insert, Update, Delete, hay 1 procedure = cach viet cau lenh "exec sp_fgsd"
        /// Input: cau lenh sql
        /// Output: Boolean (thanh cong hay khong ?)
        /// </summary>
        /// <param name="SQL">delect * from tbl_test</param>
        /// <param name="SQL">exec sp_fgsd</param>
        /// <returns></returns>
        public bool ExecuteQuery(string myQuery)
        {
            bool functionReturnValue = false;

            if ((_OpenConnection() == false))           // Open Connection
            {
                return(false);
            }

            m_Command.CommandTimeout = this.m_CommandTimeout;
            m_Command.Connection     = m_Connection;
            m_Command.CommandText    = myQuery;
            m_Command.CommandType    = CommandType.Text;

            try
            {
                CLog.LogSQL(CBase.GetDeepCaller(), myQuery);                            // log SQL

                DateTime dtBegin = DateTime.Now;                                        // duration
                m_Command.ExecuteNonQuery();
                this.m_dblDuration  = DateTime.Now.Subtract(dtBegin).TotalMilliseconds; // duration
                functionReturnValue = true;
            }
            catch (Exception ex)
            {
                functionReturnValue = false;
                CLog.LogError(CBase.GetDeepCaller(), CBase.GetDetailError(ex));
            }
            finally
            {
                _CloseConnection();     // Close Connection
            }
            return(functionReturnValue);
        }
        // GET: Group/Detail/5
        public ActionResult DetailBooking(string BookingCode)
        {
            List <string> json = new List <string>();
            DataSet       ds   = new DataSet();

            try
            {
                UserID    = Session[CConfig.SESSION_USERID] == null ? 1 : Convert.ToInt32(Session[CConfig.SESSION_USERID]);
                HotelCode = Session[CConfig.SESSION_HOTELCODE].ToString();

                //Lấy danh sách giá thời điểm
                ViewData["giathoidiem"] = new SelectList(data.GetList_DefineCategory("GIATHOIDIEM", UserID), "Value", "Name");
                //Lấy danh sách khung giá phòng
                ViewData["khunggiaphong"] = new SelectList(data.GetList_DefineCategory("KHUNGGIAPHONG", UserID), "Value", "Name");

                if (HotelCode == null)
                {
                    Response.Redirect("Receptionist/BookingList");
                }
                json = data.GetReservationRoom_Detail(BookingCode, HotelCode, UserID);
                //ds = data.GetReservationRoom_Detail( BookingCode, HotelCode, UserID);
                //Thông tin đặt phòng
                ViewData["BookingInfo"] = json[0];
                // thong tin phong
                ViewData["SetRoom"] = json[1];
                //Thông tin khách hàng
                ViewData["CustomerInfo"] = json[2];
            }
            catch (Exception ex)
            {
                CLog.LogError(CBase.GetDeepCaller(), CBase.GetDetailError(ex));
            }
            return(View());
        }
示例#10
0
        //Ham nay thuc hien viec ket noi voi database
        //COMMAND => The time in seconds to wait for the command to execute. The default is 30 seconds.
        public bool _OpenConnection()
        {
            bool functionReturnValue = false;

            try
            {
                if (m_Connection == null || m_Connection.State == ConnectionState.Closed) // 2015-07-16 09:33:40 ngocta2 => bug: open 2 connection, close 1
                {
                    // CHUA OPEN roi thi tao new connection
                    m_Connection = new SqlConnection(this.m_ConnectionString);
                    m_Connection.Open();
                    functionReturnValue = true;
                }
                else
                {
                    if (m_Connection.State == ConnectionState.Open)
                    {
                        // OPEN roi thi ko tao connection nua
                        functionReturnValue = true;
                    }
                }
            }
            catch (Exception ex)
            {
                functionReturnValue = false;
                CLog.LogError(CBase.GetDeepCaller(), CBase.GetDetailError(ex));
            }
            return(functionReturnValue);
        }
示例#11
0
        /// <summary>
        /// ExecuteSP
        /// Thuc hien 1 store procedure Insert, Update, Delete
        /// Input: 1. spName: ten store
        ///        2. myParamArray() : mang cac tham so truyen va
        /// Output: Boolean (thanh cong hay khong ?)
        /// </summary>
        /// <param name="SPname">sp_DELETE_ALL</param>
        /// <returns></returns>
        public bool ExecuteSP(string SPname)
        {
            bool functionReturnValue = false;

            if ((_OpenConnection() == false))           // Open Connection
            {
                return(false);
            }

            m_Command.Connection  = m_Connection;
            m_Command.CommandText = SPname;
            m_Command.CommandType = CommandType.StoredProcedure;

            try
            {
                CLog.LogSQL(CBase.GetDeepCaller(), SPname + this.GetParamInfo());      // log SQL

                DateTime dtBegin = DateTime.Now;                                       // duration
                m_Command.ExecuteNonQuery();
                this.m_dblDuration = DateTime.Now.Subtract(dtBegin).TotalMilliseconds; // duration
                m_Command.Parameters.Clear();
                functionReturnValue = true;
            }
            catch (Exception ex)
            {
                functionReturnValue = false;
                CLog.LogError(CBase.GetDeepCaller(), CBase.GetDetailError(ex));
            }
            finally
            {
                _CloseConnection();     // Close Connection
            }
            return(functionReturnValue);
        }
        public bool checkPermission(DataTable dt, string str, string action)
        {
            bool result = false;

            DataRow[] dtSelect = new DataRow[dt.Rows.Count];
            try
            {
                dtSelect = dt.Select("Model = '" + str + "'");
                foreach (DataRow row in dtSelect)
                {
                    if (row[action].ToString() == "1")
                    {
                        if (result == false)
                        {
                            result = true;
                        }
                        else
                        {
                            break;
                        }
                    }
                }
                //if (dt.Select("Model = '"+ str +"'")[0][action].ToString() == "True")
            }
            catch (Exception ex)
            {
                result = false;
                CLog.LogError(CBase.GetDeepCaller(), CBase.GetDetailError(ex));
            }
            return(result);
        }
示例#13
0
        //===================================== Add Brand =====================================//
        static public SportModels.ResponseModel Api_Sport_Brand_Add_BLL(SportModels.BrandModel BM)
        {
            SportModels.ResponseModel RM = new SportModels.ResponseModel();

            try
            {
                //lay du lieu tu DAL, return
                SportModels.DALOutput DALO = new SportModels.DALOutput();

                DALO = CSqlSport.Api_Sport_Brand_Add_DAL(BM);

                // response info (success)
                RM.Code    = DALO.ErrorCode;
                RM.Message = DALO.ErrorMessage;
                RM.Data    = DALO.SqlData;
            }
            catch (Exception ex)
            {
                // log error
                CLog.LogError(CBase.GetDeepCaller(), CBase.GetDetailError(ex));
                // response info (error)
                RM.Code    = CBase.GetLayerErrorCode(CBase.LAYER.BLL);
                RM.Message = ex.Message;
                RM.Data    = null;
            }

            // return
            return(RM);
        }
        // GET: Group/Edit/5
        public ActionResult Edit(int id)
        {
            try
            {
                GroupModels Group = new GroupModels();
                UserID = Session[CConfig.SESSION_USERID] == null ? 1 : Convert.ToInt32(Session[CConfig.SESSION_USERID]);

                Group = data.GetGroupByID(id);
                ViewData["ListRule"] = data.GetAccessRights(id);
                TempData["MenuList"] = new SelectList(data.GetListMenu(), "ID", "Name");
                TempData.Keep("MenuList");

                ViewData["ListGroupType"] = new SelectList(data.GetGroupTypeList(UserID), "ID", "NameVN", Group.GroupType);
                ViewData["Hotel"]         = new SelectList(dataNam.getListHotels(), "Code", "Name", Group.SysHotelCode);

                TempData["ListGroupMenu"] = data.GetListGroupMenu(id);
                TempData.Keep("ListGroupMenu");
                return(View(Group));
            }
            catch (Exception ex)
            {
                CLog.LogError(CBase.GetDeepCaller(), CBase.GetDetailError(ex));
                return(View());
            }
        }
        public List <AccessRightModels> UserHasPermission()
        {
            List <AccessRightModels> _buildList = new List <AccessRightModels>();
            DataSet   ds     = new DataSet();
            DataTable dt     = new DataTable();
            int       UserID = -1;

            try
            {
                if (HttpContext.Current.Session[CConfig.SESSION_USERID] == null)
                {
                    HttpContext.Current.Response.Redirect("/Accounts/Login");
                }
                else
                {
                    UserID = Convert.ToInt32(HttpContext.Current.Session[CConfig.SESSION_USERID]);
                }

                if (HttpContext.Current.Session[CConfig.SESSION_RIGHT_PERMISSION] != null)
                {
                    dt = (DataTable)HttpContext.Current.Session[CConfig.SESSION_RIGHT_PERMISSION];
                }
                else
                {
                    para              = new SqlParameter[1];
                    para[0]           = new SqlParameter("@UserID", SqlDbType.Int);
                    para[0].Direction = ParameterDirection.Input;
                    para[0].Value     = UserID;
                    ds = helper.ExecuteQuery(CConfig.SP_GET_RIGHT_PERMISSION, para, CommandType.StoredProcedure);

                    if (ds.Tables[0].Rows.Count > 0)
                    {
                        dt = ds.Tables[0];
                        HttpContext.Current.Session[CConfig.SESSION_RIGHT_PERMISSION] = dt;
                    }
                }
                if (dt.Rows.Count > 0)
                {
                    _buildList.Add(new AccessRightModels
                    {
                        RuleID    = Convert.ToInt32(dt.Rows[0]["RuleID"].ToString()),
                        ModelName = dt.Rows[0]["ModelID"].ToString(),
                        Read      = Convert.ToBoolean(dt.Rows[0]["Read"].ToString()),
                        Write     = Convert.ToBoolean(dt.Rows[0]["Write"].ToString()),
                        Create    = Convert.ToBoolean(dt.Rows[0]["Create"].ToString()),
                        Delete    = Convert.ToBoolean(dt.Rows[0]["Delete"].ToString())
                    });
                }
            }
            catch (Exception ex)
            {
                _buildList = null;
                CLog.LogError(CBase.GetDeepCaller(), CBase.GetDetailError(ex));
            }

            return(_buildList);
        }
示例#16
0
        /// <summary>
        /// bo ky tu ko hop le
        /// C:\Log\Monitor\ERROR\2016-04-08\103843__System.Threading.QueueUserWorkItemCallback_WaitCallback_Context_Monitor.Hubs.CMonitor5G_<InitPubSubData>b__0___xgbmys1i.5tx
        /// Illegal characters in path.
        /// </summary>
        /// <param name="strPath"></param>
        /// <returns></returns>
        public static string FixPath(string strPath)
        {
            try
            {
                strPath = strPath.Replace("<", "(");
                strPath = strPath.Replace(">", ")");
                strPath = strPath.Replace("`", "_");

                return(strPath);
            }
            catch (Exception ex)
            {
                CLog.LogError(CBase.GetDeepCaller(), CBase.GetDetailError(ex));
                return(strPath);
            }
        }
        public JsonResult SearchBooking(ReservationRoomModel mdReservationRoom, int CurrentPage, int NumInPage)
        {
            object[] message = new object[1];
            UserID    = Session[CConfig.SESSION_USERID] == null ? 1 : Convert.ToInt32(Session[CConfig.SESSION_USERID]);
            HotelCode = Session[CConfig.SESSION_HOTELCODE] == null ? "OzeHotelxxxx" : Session[CConfig.SESSION_HOTELCODE].ToString();
            try
            {
                if (mdReservationRoom != null)
                {
                    message[0] = data.getObjectCustomer_Booking(mdReservationRoom, HotelCode, UserID, CurrentPage, NumInPage);
                }
            }
            catch (Exception ex)
            {
                CLog.LogError(CBase.GetDeepCaller(), CBase.GetDetailError(ex));
            }

            return(Json(new { mess = message }, JsonRequestBehavior.AllowGet));
        }
        public DataTable tbUserHasPermission()
        {
            DataSet   ds     = new DataSet();
            DataTable dt     = new DataTable();
            int       UserID = -1;

            try
            {
                if (HttpContext.Current.Session[CConfig.SESSION_USERID] == null)
                {
                    HttpContext.Current.Response.Redirect("/Accounts/Login");
                }
                else
                {
                    UserID = Convert.ToInt32(HttpContext.Current.Session[CConfig.SESSION_USERID]);
                }

                if (HttpContext.Current.Session[CConfig.SESSION_RIGHT_PERMISSION] != null)
                {
                    dt = (DataTable)HttpContext.Current.Session[CConfig.SESSION_RIGHT_PERMISSION];
                }
                else
                {
                    para              = new SqlParameter[1];
                    para[0]           = new SqlParameter("@UserID", SqlDbType.Int);
                    para[0].Direction = ParameterDirection.Input;
                    para[0].Value     = UserID;
                    ds = helper.ExecuteQuery(CConfig.SP_GET_RIGHT_PERMISSION, para, CommandType.StoredProcedure);

                    if (ds.Tables[0].Rows.Count > 0)
                    {
                        dt = ds.Tables[0];
                        HttpContext.Current.Session[CConfig.SESSION_RIGHT_PERMISSION] = dt;
                    }
                }
            }
            catch (Exception ex)
            {
                dt = null;
                CLog.LogError(CBase.GetDeepCaller(), CBase.GetDetailError(ex));
            }
            return(dt);
        }
 protected HttpResponseMessage CreateJsonResponse(object objData)
 {
     try
     {
         // header/contentType - JSON
         MediaTypeHeaderValue MTHV = new MediaTypeHeaderValue(CConfigDS.RESPONSE_CONTENT_TYPE_JSON);
         // create response, code 200
         HttpResponseMessage HRM = Request.CreateResponse(HttpStatusCode.OK, objData, MTHV);
         // return
         return(HRM);
     }
     catch (Exception ex)
     {
         // log error
         CLog.LogError(CBase.GetDeepCaller(), CBase.GetDetailError(ex));
         // create response, code 500
         return(Request.CreateResponse(HttpStatusCode.InternalServerError));
     }
 }
        public HttpResponseMessage Api_Sport_Category_Update(SportModels.CategoryModel CM)
        {
            SportModels.ResponseModel RM = new SportModels.ResponseModel();
            try
            {
                // 1. get data
                RM = CSport.Api_Sport_Category_Update_BLL(CM);

                // 2. return response (code 200)
                return(CreateJsonResponse(RM));
            }
            catch (Exception ex)
            {
                // log error
                CLog.LogError(CBase.GetDeepCaller(), CBase.GetDetailError(ex));
                // return error code
                return(Request.CreateResponse(HttpStatusCode.InternalServerError));
            }
        }
示例#21
0
 //Ham nay dung de dong 1 connection den database
 public void _CloseConnection()
 {
     try
     {
         if ((m_Connection.State == ConnectionState.Open))
         {
             m_Connection.Close();
             m_Connection.Dispose();
             m_Command.Dispose();
         }
     }
     catch (Exception ex)
     {
         CLog.LogError(CBase.GetDeepCaller(), CBase.GetDetailError(ex));
     }
     finally
     {
     }
 }
示例#22
0
        //===================================== Add Brand =====================================//
        public static SportModels.DALOutput Api_Sport_Brand_Add_DAL(SportModels.BrandModel BM)
        {
            DataSet ds = new DataSet();

            try
            {
                SqlParameter[] arrParams = new SqlParameter[3];

                // input params
                arrParams[0]           = new SqlParameter("brandName", SqlDbType.NVarChar, 50);
                arrParams[0].Direction = ParameterDirection.Input;
                arrParams[0].Value     = BM.BrandName;

                // input params
                arrParams[1]           = new SqlParameter("brandURL", SqlDbType.NVarChar, 200);
                arrParams[1].Direction = ParameterDirection.Input;
                arrParams[1].Value     = BM.BrandURL;

                // input params
                arrParams[2]           = new SqlParameter("createdDate", SqlDbType.Date);
                arrParams[2].Direction = ParameterDirection.Input;
                arrParams[2].Value     = BM.CreatedDate;

                // exec
                ds = SqlHelper.ExecuteDataset(CConfigDS.CONNECTION_STRING_SQL_SPORT_SHOP, CommandType.StoredProcedure, CConfigDS.SPORT_SHOP_SQL_SP_BRAND_ADD, arrParams);

                // return (neu sp ko tra error code,msg thi tu gan default)
                return(new SportModels.DALOutput()
                {
                    ErrorCode = CConfigDS.RESPONSE_CODE_SUCCESS, ErrorMessage = CConfigDS.RESPONSE_MSG_SUCCESS, SqlData = ds
                });
            }
            catch (Exception ex)
            {
                // log error
                CLog.LogError(CBase.GetDeepCaller(), CBase.GetDetailError(ex));
                // error => return null
                return(new SportModels.DALOutput()
                {
                    ErrorCode = CBase.GetLayerErrorCode(CBase.LAYER.DAL), ErrorMessage = ex.Message, SqlData = null
                });
            }
        }
        /// <summary>
        /// Ajax form: Create Group Menu
        /// </summary>
        /// <param name="SysMenuID"></param>
        /// <param name="SysGroupID"></param>
        /// <returns></returns>
        public JsonResult CreateGroupMenu(string SysMenuID, string SysGroupID)
        {
            string result;
            string Count = "0";

            try
            {
                SysGroupMenu_RelModels objGroupMenu = new SysGroupMenu_RelModels();
                DataSet ds      = new DataSet();
                int     MenuID  = string.IsNullOrEmpty(SysMenuID) ? 0 : Int32.Parse(SysMenuID.ToString());
                int     GroupID = string.IsNullOrEmpty(SysGroupID) ? 0 : Int32.Parse(SysGroupID.ToString());
                int     UserID  = Session[CConfig.SESSION_USERID].ToString() == "" ? 1 : Convert.ToInt32(Session[CConfig.SESSION_USERID]);
                objGroupMenu.SysMenuID  = MenuID;
                objGroupMenu.SysGroupID = GroupID;
                objGroupMenu.UserID     = UserID;

                ds = data.CreateGroupMenuRel(objGroupMenu);

                if (ds.Tables[1].Rows.Count > 0)
                {
                    Count = ds.Tables[1].Rows[0][0].ToString();
                    var row = ds.Tables[1].Rows[0];
                    List <SysGroupMenu_RelModels> list = new List <SysGroupMenu_RelModels>();
                    list.Add(new SysGroupMenu_RelModels {
                        ID         = Convert.ToInt32(row["ID"].ToString().Trim()),
                        SysGroupID = Convert.ToInt32(row["SysGroupID"].ToString().Trim()),
                        Name       = row["Name"].ToString().Trim(),
                        Level      = Convert.ToInt32(row["Level"].ToString().Trim())
                    });
                    ViewData["ListGroupMenu"] = list;// ds.Tables[1];
                }
                result = ds.Tables[0].Rows[0][0].ToString();
            }
            catch (Exception ex)
            {
                result = "Error: Không thêm được menu vào group";
                Count  = null;
                CLog.LogError(CBase.GetDeepCaller(), CBase.GetDetailError(ex));
            }

            return(Json(new { mess = result, Count = Count, data = ViewData["ListGroupMenu"] == null ? null : ViewData["ListGroupMenu"] }, JsonRequestBehavior.AllowGet));
        }
        public JsonResult Transfer_SetRoomForBooking(tbl_Reservation_Room ReserModel, tbl_Reservation_Room_tbl_Room_Rel Rel_model)
        {
            object message = new object();

            try
            {
                UserID = Session[CConfig.SESSION_USERID] == null ? 1 : Convert.ToInt32(Session[CConfig.SESSION_USERID]);

                if (ReserModel != null & Rel_model != null & ModelState.IsValid)
                {
                    message = data.Transfer_SetRoomForBooking(ReserModel, Rel_model);
                }
            }
            catch (Exception ex)
            {
                message = "Đổi phòng phòng không thành công!";
                CLog.LogError(CBase.GetDeepCaller(), CBase.GetDetailError(ex));
            }

            return(Json(new { mess = message }, JsonRequestBehavior.AllowGet));
        }
        /// <summary>
        ///
        /// kiem tra request hop le, co quyen truy cap du lieu ko
        /// </summary>
        /// <returns></returns>
        protected bool AuthenticateRequest()
        {
            try
            {
                // check header (token) => se them trong tuong lai
                // ......
                // ......
                // ......
                // ......

                // return
                return(true);
            }
            catch (Exception ex)
            {
                // log error
                CLog.LogError(CBase.GetDeepCaller(), CBase.GetDetailError(ex));
                // false
                return(false);
            }
        }
        // POST: Group/Create
        public JsonResult CreateGroup(GroupDetailModel Group)
        {
            DataSet ds = new DataSet();

            object[] message = new object[1];
            try
            {
                if (Group != null & ModelState.IsValid)
                {
                    ds         = data.CreateGroup(Group);
                    message[0] = ds.Tables[0].Rows[0]["sMess"].ToString();
                }
            }
            catch (Exception ex)
            {
                message[0] = "Error: Không thêm được nhóm quyền!";
                CLog.LogError(CBase.GetDeepCaller(), CBase.GetDetailError(ex));
            }

            return(Json(new { mess = message }, JsonRequestBehavior.AllowGet));
        }
 /// <summary>
 ///
 /// tao response ko co quyen, tra ve client
 /// </summary>
 /// <returns></returns>
 protected HttpResponseMessage CreateAccessDeniedResponse()
 {
     try
     {
         return(CreateJsonResponse(
                    new SportModels.ResponseModel()
         {
             Code = CConfigDS.RESPONSE_CODE_ACCESS_DENIED,
             Message = CConfigDS.RESPONSE_MSG_ACCESS_DENIED,
             Data = CConfigDS.RESPONSE_DATA_NULL
         }
                    ));
     }
     catch (Exception ex)
     {
         // log error
         CLog.LogError(CBase.GetDeepCaller(), CBase.GetDetailError(ex));
         // create response, code 500
         return(Request.CreateResponse(HttpStatusCode.InternalServerError));
     }
 }
        // POST: Group/Delete/5
        //[HttpPost]
        public JsonResult DeleteGroup(int id = 0)
        {
            object[] message = { };
            DataSet  ds      = new DataSet();

            try
            {
                // TODO: Add delete logic here
                if (id != 0)
                {
                    //ds = data.DeleteGroupMenuRel
                }
                //return RedirectToAction("Index");
            }
            catch (Exception ex)
            {
                CLog.LogError(CBase.GetDeepCaller(), CBase.GetDetailError(ex));
                //return View();
            }
            return(Json(new { mess = message }, JsonRequestBehavior.AllowGet));
        }
        // POST: /Receptionist/SetRoomForReservationRoom
        public JsonResult SetRoomForReservationRoom(tbl_Reservation_Room_tbl_Room_Rel model)
        {
            object[] message = new object[1];
            try
            {
                UserID          = Session[CConfig.SESSION_USERID] == null ? 1 : Convert.ToInt32(Session[CConfig.SESSION_USERID]);
                model.HotelCode = HotelCode;

                if (model != null & ModelState.IsValid)
                {
                    message[0] = data.Create_RoomforReservationRoom(model, UserID);
                }
            }
            catch (Exception ex)
            {
                message[0] = "Gán phòng không thành công!";
                CLog.LogError(CBase.GetDeepCaller(), CBase.GetDetailError(ex));
            }

            return(Json(new { mess = message }, JsonRequestBehavior.AllowGet));
        }
示例#30
0
 //<add key="BASE_TEMPLATE_LOG_EX_FILENAME"      value="(thread)__(type)__(hh)_(mm)_(ss)__(random).(ext)" />
 //"1__security__14_33_55__abcd7890"
 //CLog.LogEx("TEST", "1__security__14_33_55__abcd7890", "Tạm ứng cổ tức năm đợt 2 năm 2014 bằng tiền mặt, 2.000đồng/cổ phiếu");
 public static string GetLogExFileName(int intThread, string strType, string strExt)
 {
     try
     {
         string strFileName = CConfig.BASE_TEMPLATE_LOG_EX_FILENAME;
         strFileName = strFileName
                       .Replace("(thread)", intThread.ToString())
                       .Replace("(type)", strType)
                       .Replace("(hh)", CBase.Right("00" + DateTime.Now.Hour.ToString(), 2))
                       .Replace("(mm)", CBase.Right("00" + DateTime.Now.Minute.ToString(), 2))
                       .Replace("(ss)", CBase.Right("00" + DateTime.Now.Second.ToString(), 2))
                       .Replace("(random)", System.IO.Path.GetRandomFileName())
                       .Replace("(ext)", strExt);
         return(strFileName);
     }
     catch (Exception ex)
     {
         CLog.LogError(CBase.GetDeepCaller(), CBase.GetDetailError(ex));
         return("");
     }
 }