예제 #1
0
        public ActionResult ManageAssetDoc(AppraisalDetailModel model, string appraisalManageType)//เอกสารสิทธิ์
        {
            try
            {
                TempData["appraisalManageType"] = appraisalManageType != string.Empty ? appraisalManageType : "";
                getAppraisalAssetCode(model.appraisal_assets_id);
                setAssetDoc();

                if (ModelState.IsValid && model.type_of_document_id != 0)
                {
                    string userName = ContentHelpers.Decode(Convert.ToString(Session["UserName"]));
                    var    process  = AppraisalService.MngAppraisalDetail(model, userName);
                    if (process)
                    {
                        List <AppraisalDetailModel> modelList = AppraisalService.GetAppraisalDetail(model.assets_detail_id, model.appraisal_assets_id, userName);
                        if (ContentHelpers.IsNotnull(modelList) && modelList.Count > 0)
                        {
                            model = modelList[0];

                            string _appraisalManageType = ContentHelpers.Decode(appraisalManageType);
                            string thisManageType       = _appraisalManageType;
                            if (_appraisalManageType != "u")
                            {
                                appraisalManageType = ContentHelpers.Encode(appraisalManageType);
                            }

                            return(RedirectToAction(
                                       "ManageAssetDocPic",
                                       new RouteValueDictionary(new
                            {
                                appraisalID = ContentHelpers.Encode(model.appraisal_assets_id.ToString()),
                                appraisalManageType = appraisalManageType
                            })
                                       ));
                        }
                    }
                    else
                    {
                        ViewData["alert"] = ContentHelpers.getAlertBox(DataInfo.AlertStatusId.ERROR, "จัดการข้อมูลไม่สำเร็จ!");
                    }
                }
                else
                {
                    if (model.type_of_document_id == 0)
                    {
                        ViewData["type_of_document_id"] = "false";
                    }
                }
            }
            catch (ArgumentException ae)
            {
                ModelState.AddModelError(String.Empty, ae.Message);
            }
            catch (Exception e)
            {
                ModelState.AddModelError(String.Empty, e.Message);
            }

            return(View(model));
        }
예제 #2
0
        public ActionResult ManageMaterial(LocationAssetModel model, string appraisalManageType)//สิ่งปลูกสร้าง
        {
            try
            {
                TempData["appraisalManageType"] = appraisalManageType != string.Empty ? appraisalManageType : "";
                getAppraisalAssetCode(model.appraisal_assets_id);
                setMaterial();

                if (ModelState.IsValid)
                {
                    string userName = ContentHelpers.Decode(Convert.ToString(Session["UserName"]));
                    var    process  = AppraisalService.MngLocationAsset(model, userName);
                    if (process)
                    {
                        List <LocationAssetModel> modelList = AppraisalService.GetLocationAsset(0, model.appraisal_assets_id, userName);
                        if (ContentHelpers.IsNotnull(modelList) && modelList.Count > 0)
                        {
                            model = modelList[0];

                            string _appraisalManageType = ContentHelpers.Decode(appraisalManageType);
                            string thisManageType       = _appraisalManageType;
                            if (_appraisalManageType != "u")
                            {
                                appraisalManageType = ContentHelpers.Encode(appraisalManageType);
                            }

                            return(RedirectToAction(
                                       "ManageCompareAsset",
                                       new RouteValueDictionary(new
                            {
                                appraisalID = ContentHelpers.Encode(model.appraisal_assets_id.ToString()),
                                appraisalManageType = appraisalManageType
                            })
                                       ));
                        }
                    }
                    else
                    {
                        ViewData["alert"] = ContentHelpers.getAlertBox(DataInfo.AlertStatusId.ERROR, "จัดการข้อมูลไม่สำเร็จ!");
                    }
                }
            }
            catch (ArgumentException ae)
            {
                ModelState.AddModelError(String.Empty, ae.Message);
            }
            catch (Exception e)
            {
                ModelState.AddModelError(String.Empty, e.Message);
            }
            return(View(model));
        }
예제 #3
0
        public ActionResult ManageOtherDetail(string appraisalID, string appraisalManageType)//รายละเอียดเพิ่มเติม
        {
            List <CompareDescriptionModel> modelList = new List <CompareDescriptionModel>();

            // TempData["AppraisalCode"] = Convert.ToInt32(TempData["AppraisalCode"]);

            int thisID = Convert.ToInt32(ContentHelpers.Decode(appraisalID));

            getAppraisalAssetCode(thisID);
            string thisManageType = ContentHelpers.Decode(appraisalManageType);

            TempData["appraisalManageType"] = appraisalManageType != string.Empty ? ContentHelpers.Decode(appraisalManageType) : "";

            try
            {
                if (ContentHelpers.IsNotnull(thisID) && thisID > 0)
                {
                    modelList = AppraisalService.GetCompareDescription(0, thisID, "");
                }
                else
                {
                    if (modelList == null)
                    {
                        modelList = new List <CompareDescriptionModel>();
                        for (int i = 1; i < 5; i++)
                        {
                            CompareDescriptionModel compareDesc = new CompareDescriptionModel();
                            compareDesc.appraisal_assets_id = thisID;
                            compareDesc.sequence            = i;
                            modelList.Add(compareDesc);
                        }
                    }
                }
            }
            catch (ArgumentException ae)
            {
                ModelState.AddModelError(String.Empty, ae.Message);
            }
            catch (Exception e)
            {
                ModelState.AddModelError(String.Empty, e.Message);
            }
            return(View(modelList));
        }
예제 #4
0
        public ActionResult GetUserList(string keyword)
        {
            try
            {
                string           userName = ContentHelpers.Decode(Convert.ToString(Session["UserName"]));
                List <UserModel> userList = MembershipService.GetUsers(keyword);
                if (ContentHelpers.IsNotnull(userList) && userList.Count > 0)
                {
                    ViewData["UserList"] = userList;
                }
                else
                {
                    ModelState.AddModelError("", "Search data not found.");
                }
            }
            catch (Exception e)
            {
                ModelState.AddModelError(String.Empty, e.Message);
            }

            return(View());
        }
예제 #5
0
        public ActionResult ManageAssetDoc(string appraisalID, string appraisalManageType)//เอกสารสิทธิ์
        {
            AppraisalDetailModel model = new AppraisalDetailModel();
            //model.appraisal_assets_id = Convert.ToInt32(TempData["AppraisalID"]);
            //TempData["AppraisalCode"] = Convert.ToInt32(TempData["AppraisalCode"]);

            int thisID = Convert.ToInt32(ContentHelpers.Decode(appraisalID));

            model.appraisal_assets_id = thisID;
            getAppraisalAssetCode(thisID);
            string thisManageType = ContentHelpers.Decode(appraisalManageType);

            TempData["appraisalManageType"] = appraisalManageType != string.Empty ? ContentHelpers.Decode(appraisalManageType) : "";

            try
            {
                setAssetDoc();

                if (ContentHelpers.IsNotnull(thisID) && thisID > 0)
                {
                    List <AppraisalDetailModel> modelList = AppraisalService.GetAppraisalDetail(0, thisID, "");
                    if (ContentHelpers.IsNotnull(modelList) && modelList.Count > 0)
                    {
                        model = modelList[0];
                    }
                }
            }
            catch (ArgumentException ae)
            {
                ModelState.AddModelError(String.Empty, ae.Message);
            }
            catch (Exception e)
            {
                ModelState.AddModelError(String.Empty, e.Message);
            }

            return(View(model));
        }
예제 #6
0
        public List <FilterModel> GetFilterLists(string filterType)
        {
            MySqlConnection    conn       = null;
            List <FilterModel> filterList = null;

            try
            {
                using (conn = new MySqlConnection(GetConnectionString()))
                {
                    if (conn.State == ConnectionState.Closed)
                    {
                        conn.Open();
                    }

                    string QueryCmd = Resources.SQLResource.VIEW_FILTER;
                    if (ContentHelpers.IsNotnull(filterType))
                    {
                        QueryCmd += " WHERE FILTER_TYPE_NAME = '" + filterType + "'";
                    }

                    using (MySqlCommand cmd = new MySqlCommand(QueryCmd, conn))
                    {
                        using (MySqlDataReader dr = cmd.ExecuteReader(CommandBehavior.CloseConnection))
                        {
                            if (dr.HasRows)
                            {
                                filterList = new List <FilterModel>();
                                FilterModel IndexFilterItem = new FilterModel();
                                IndexFilterItem.filter_value = 0;
                                IndexFilterItem.filter_text  = "โปรดเลือก";

                                filterList.Add(IndexFilterItem);
                                while (dr.Read())
                                {
                                    FilterModel FilterItem = new FilterModel();
                                    FilterItem.filter_type_code = dr["filter_type_code"] == System.DBNull.Value ? "" : Convert.ToString(dr["filter_type_code"]);
                                    FilterItem.filter_type_name = dr["filter_type_name"] == System.DBNull.Value ? "" : Convert.ToString(dr["filter_type_name"]);
                                    FilterItem.filter_value     = dr["filter_value"] == System.DBNull.Value ? 0 : Convert.ToInt32(dr["filter_value"]);
                                    FilterItem.filter_text      = dr["filter_text"] == System.DBNull.Value ? "" : Convert.ToString(dr["filter_text"]);

                                    filterList.Add(FilterItem);
                                }
                            }
                        }
                    }
                }
            }
            catch (MySqlException ms)
            {
                throw new Exception("MySqlException: " + ms.Message);
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                conn.Close();
                conn.Dispose();
            }

            return(filterList);
        }
예제 #7
0
        public List <UserModel> GetUsers(string keyword)
        {
            // The underlying ChangePassword() will throw an exception rather
            // than return false in certain failure scenarios.
            MySqlConnection  conn         = null;
            List <UserModel> UserItemList = null;
            DateTime?        Nullable     = null;

            try
            {
                using (conn = new MySqlConnection(GetConnectionString()))
                {
                    if (conn.State == ConnectionState.Closed)
                    {
                        conn.Open();
                    }

                    using (MySqlCommand cmd = new MySqlCommand(Resources.SQLResource.VIEW_USERS, conn))
                    {
                        cmd.CommandText += string.Format(" WHERE DELETE_FLAG =  0 ");
                        if (ContentHelpers.IsNotnull(keyword))
                        {
                            cmd.CommandText += string.Format(" AND USER_NAME LIKE '%{0}%' OR CITIZEN_ID LIKE '%{0}%' OR NAME LIKE '%{0}%'", keyword);
                        }
                        using (MySqlDataReader dr = cmd.ExecuteReader(CommandBehavior.CloseConnection))
                        {
                            if (dr.HasRows)
                            {
                                UserItemList = new List <UserModel>();
                                while (dr.Read())
                                {
                                    UserModel UserItem = new UserModel();
                                    UserItem.UserID      = dr["USER_ID"] == System.DBNull.Value ? 0 : Convert.ToInt32(dr["USER_ID"]);
                                    UserItem.UserName    = dr["USER_NAME"] == System.DBNull.Value ? "" : Convert.ToString(dr["USER_NAME"]);
                                    UserItem.RoleID      = dr["ROLE_ID"] == System.DBNull.Value ? 0 : Convert.ToInt32(dr["ROLE_ID"]);
                                    UserItem.RoleCode    = dr["ROLE_CODE"] == System.DBNull.Value ? "" : Convert.ToString(dr["ROLE_CODE"]);
                                    UserItem.RoleName    = dr["ROLE_NAME"] == System.DBNull.Value ? "" : Convert.ToString(dr["ROLE_NAME"]);
                                    UserItem.CitizenID   = dr["CITIZEN_ID"] == System.DBNull.Value ? "" : Convert.ToString(dr["CITIZEN_ID"]);
                                    UserItem.Name        = dr["NAME"] == System.DBNull.Value ? "" : Convert.ToString(dr["NAME"]);
                                    UserItem.Email       = dr["EMAIL"] == System.DBNull.Value ? "" : Convert.ToString(dr["EMAIL"]);
                                    UserItem.Phone       = dr["PHONE"] == System.DBNull.Value ? "" : Convert.ToString(dr["PHONE"]);
                                    UserItem.Last_Login  = dr["LAST_LOGIN"] == System.DBNull.Value ? Nullable : Convert.ToDateTime(dr["LAST_LOGIN"]);
                                    UserItem.User_Login  = dr["USER_LOGIN"] == System.DBNull.Value ? 0 : Convert.ToInt32(dr["USER_LOGIN"]);
                                    UserItem.DeleteFlag  = dr["DELETE_FLAG"] == System.DBNull.Value ? 0 : Convert.ToInt32(dr["DELETE_FLAG"]);
                                    UserItem.Create_Date = dr["CREATE_DATE"] == System.DBNull.Value ? Nullable : Convert.ToDateTime(dr["CREATE_DATE"]);
                                    UserItem.Update_Date = dr["UPDATE_DATE"] == System.DBNull.Value ? Nullable : Convert.ToDateTime(dr["UPDATE_DATE"]);
                                    UserItem.Delete_Date = dr["DELETE_DATE"] == System.DBNull.Value ? Nullable : Convert.ToDateTime(dr["DELETE_DATE"]);
                                    UserItem.Create_By   = dr["CREATE_BY"] == System.DBNull.Value ? "" : Convert.ToString(dr["CREATE_BY"]);
                                    UserItem.Update_By   = dr["UPDATE_BY"] == System.DBNull.Value ? "" : Convert.ToString(dr["UPDATE_BY"]);
                                    UserItem.Delete_By   = dr["DELETE_BY"] == System.DBNull.Value ? "" : Convert.ToString(dr["DELETE_BY"]);
                                    UserItem.Status      = dr["STATUS"] == System.DBNull.Value ? 0 : Convert.ToInt32(dr["STATUS"]);
                                    UserItemList.Add(UserItem);
                                }
                            }
                        }
                    }
                }
            }
            catch (MySqlException ms)
            {
                throw new Exception("MySqlException: " + ms.Message);
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                conn.Close();
                conn.Dispose();
            }
            return(UserItemList);
        }
예제 #8
0
        public Hashtable ValidateUser(string userName, string password)
        {
            if (String.IsNullOrEmpty(userName))
            {
                throw new ArgumentException("Value cannot be null or empty.", "userName");
            }
            if (String.IsNullOrEmpty(password))
            {
                throw new ArgumentException("Value cannot be null or empty.", "password");
            }
            MySqlConnection conn    = null;
            MySqlCommand    cmd     = null;
            Hashtable       result  = new Hashtable();
            bool            process = false;
            string          msg     = "";
            string          userId  = "";

            try
            {
                using (conn = new MySqlConnection(GetConnectionString()))
                {
                    if (conn.State == ConnectionState.Closed)
                    {
                        conn.Open();
                    }
                    using (cmd = new MySqlCommand(Resources.SQLResource.USP_GET_USERS_LOGIN, conn))
                    {
                        cmd.CommandType = CommandType.StoredProcedure;
                        cmd.Parameters.Clear();
                        cmd.Parameters.Add("iUsername", MySqlDbType.VarChar).Value = userName;
                        cmd.Parameters.Add("iPassword", MySqlDbType.VarChar).Value = ContentHelpers.MD5Hash(password);
                        cmd.Parameters.Add(new MySqlParameter("oMessage", MySqlDbType.VarChar)).Direction = ParameterDirection.Output;
                        cmd.Parameters.Add(new MySqlParameter("oUserID", MySqlDbType.Int32)).Direction    = ParameterDirection.Output;
                        cmd.ExecuteScalar();

                        int ouserId = cmd.Parameters["oUserID"].Value == System.DBNull.Value ? 0 : Convert.ToInt32(cmd.Parameters["oUserID"].Value);
                        if (ouserId > 0)
                        {
                            userId = ouserId.ToString();
                            using (cmd = new MySqlCommand(Resources.SQLResource.USP_GET_USERS_PERMISSION, conn))
                            {
                                cmd.CommandType = CommandType.StoredProcedure;
                                cmd.Parameters.Clear();
                                cmd.Parameters.Add("iUsername", MySqlDbType.VarChar).Value = userName;
                                cmd.Parameters.Add(new MySqlParameter("oMessage", MySqlDbType.VarChar)).Direction  = ParameterDirection.Output;
                                cmd.Parameters.Add(new MySqlParameter("oRoleCode", MySqlDbType.VarChar)).Direction = ParameterDirection.Output;
                                cmd.ExecuteScalar();

                                string roleCode = cmd.Parameters["oRoleCode"].Value == System.DBNull.Value ? "" :
                                                  Convert.ToString(cmd.Parameters["oRoleCode"].Value);
                                if (ContentHelpers.IsNotnull(roleCode))
                                {
                                    result["RoleCode"] = roleCode;
                                    process            = true;
                                }
                            }
                        }
                        msg = Convert.ToString(cmd.Parameters["oMessage"].Value);
                    }
                }
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                conn.Close();
                conn.Dispose();
            }
            result["Status"]  = process;
            result["Message"] = msg;
            result["userId"]  = userId;
            return(result);
        }