Exemple #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (IsPostBack)
            {
                return;
            }
            Sys_ThongSoHeThong thongsohethong = (from ds in dataContext.Sys_ThongSoHeThongs where ds.ThongSo == "APPNAME" select ds).FirstOrDefault();

            if (thongsohethong != null)
            {
                ltName.Text = thongsohethong.GiaTri;
            }
            else
            {
                ltName.Text = "HỆ THỐNG XRP";
            }
            if (Request.Cookies["xrp_username"] != null)
            {
                txtEmail.Text = Request.Cookies["xrp_username"].Value;
                txtPassword.Focus();
            }
            else
            {
                txtEmail.Focus();
            }
        }
Exemple #2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            id    = Request.QueryString["id"] ?? string.Empty;
            trang = Request.QueryString["trang"] ?? string.Empty;
            lblMessage.Visible = false;

            if (!string.IsNullOrEmpty(id))
            {
                Sys_ThongSoHeThongRepository repository = new Sys_ThongSoHeThongRepository();
                Sys_ThongSoHeThong           entity     = repository.GetById(int.Parse(id));
                txtTen.Text   = entity.ThongSo;
                txtNote.Text  = entity.MoTa;
                txtValue.Text = entity.GiaTri;

                ConfigName = entity.ThongSo;
            }
        }
Exemple #3
0
        public static string DeleteConfigItem(string itemID)
        {
            AjaxResponse response = new AjaxResponse();

            try
            {
                //Initial data context variable, this class is declared in .dbml file in xRPDAL namespace
                Sys_ThongSoHeThongRepository repository = new Sys_ThongSoHeThongRepository();
                Sys_ThongSoHeThong           entity     = repository.GetById(int.Parse(itemID));
                repository.DeleteOnSubmit(entity);
                repository.SubmitChanges();
                response.IsSuccess = true;
                response.Message   = "OK";
            }
            catch (Exception ex)
            {
                response.IsSuccess = false;
                response.Message   = (ex.Message + ex.StackTrace).EncodeJsString();
            }
            return(JsonConvert.SerializeObject(response));
        }
Exemple #4
0
        public static string AddOrUpdateConfigItem(string id, string name, string value, string note)
        {
            AjaxResponse response = new AjaxResponse();

            try
            {
                if (string.IsNullOrEmpty(id))
                {
                    Sys_ThongSoHeThongRepository repository = new Sys_ThongSoHeThongRepository();
                    Sys_ThongSoHeThong           entity     = new Sys_ThongSoHeThong();

                    string message     = string.Empty;
                    bool   isExistName = false;

                    isExistName = repository.IsExistThongSo(name);


                    if (isExistName)
                    {
                        response.IsSuccess = false;
                        message            = "Tên đã tồn tại, vui lòng nhập tên khác.\n";
                    }

                    if (isExistName)
                    {
                        response.Message = message;
                        return(JsonConvert.SerializeObject(response));
                    }

                    entity.ThongSo      = name;
                    entity.MoTa         = note;
                    entity.GiaTri       = value;
                    entity.NgayThayDoi  = DateTime.Now;
                    entity.NguoiThayDoi = Guid.NewGuid();

                    repository.InsertOnSubmit(entity);
                    repository.SubmitChanges();

                    response.IsSuccess = true;
                }
                else
                {
                    Sys_ThongSoHeThongRepository repository = new Sys_ThongSoHeThongRepository();
                    Sys_ThongSoHeThong           entity     = repository.GetById(int.Parse(id));
                    if (entity == null)
                    {
                        response.IsSuccess = false;
                        response.Message   = "Không tồn tại bản ghi";
                        return(JsonConvert.SerializeObject(response));
                    }


                    ///Check trùng tên trong trường hợp sửa
                    if (entity.ThongSo != name)
                    {
                        string message     = string.Empty;
                        bool   isExistName = repository.IsExistThongSo(name);

                        if (isExistName)
                        {
                            response.IsSuccess = false;
                            message            = "Tên đã tồn tại, vui lòng nhập tên khác.\n";
                        }

                        if (isExistName)
                        {
                            response.Message = message;
                            return(JsonConvert.SerializeObject(response));
                        }
                    }

                    entity.ThongSo      = name;
                    entity.MoTa         = note;
                    entity.GiaTri       = value;
                    entity.NgayThayDoi  = DateTime.Now;
                    entity.NguoiThayDoi = Guid.NewGuid();
                    repository.SubmitChanges();

                    response.IsSuccess = true;
                }
            }
            catch (Exception ex)
            {
                response.IsSuccess = false;
                response.Message   = (ex.Message + ex.StackTrace).EncodeJsString();
            }
            return(JsonConvert.SerializeObject(response));
        }
Exemple #5
0
        protected void btnAdd_Click(object sender, EventArgs e)
        {
            bool   isSuccess   = false;
            string message     = string.Empty;
            bool   isExistName = false;

            string name  = txtTen.Text;
            string note  = txtNote.Text;
            string value = txtValue.Text;

            if (string.IsNullOrEmpty(id))
            {
                Sys_ThongSoHeThongRepository repository = new Sys_ThongSoHeThongRepository();
                Sys_ThongSoHeThong           entity     = new Sys_ThongSoHeThong();


                isExistName = repository.IsExistThongSo(name);

                if (isExistName)
                {
                    message = "Tên đã tồn tại, vui lòng nhập tên khác.\n";
                }
                else
                {
                    try
                    {
                        entity.ThongSo      = name;
                        entity.MoTa         = note;
                        entity.GiaTri       = value;
                        entity.NgayThayDoi  = DateTime.Now;
                        entity.NguoiThayDoi = Guid.NewGuid();

                        repository.InsertOnSubmit(entity);
                        repository.SubmitChanges();
                        isSuccess = true;
                    }
                    catch
                    {
                        message = "Lỗi trong quá trình cập nhật";
                    }
                }
            }
            else
            {
                Sys_ThongSoHeThongRepository repository = new Sys_ThongSoHeThongRepository();
                Sys_ThongSoHeThong           entity     = repository.GetById(int.Parse(id));

                ConfigName = entity.ThongSo;
                ///Check trùng tên trong trường hợp sửa
                if (entity.ThongSo != name)
                {
                    isExistName = repository.IsExistThongSo(name);

                    if (isExistName)
                    {
                        message = "Tên đã tồn tại, vui lòng nhập tên khác.\n";
                    }
                }
                if (!isExistName)
                {
                    try
                    {
                        entity.ThongSo      = name;
                        entity.MoTa         = note;
                        entity.GiaTri       = value;
                        entity.NgayThayDoi  = DateTime.Now;
                        entity.NguoiThayDoi = Guid.NewGuid();
                        repository.SubmitChanges();
                        isSuccess = true;
                    }
                    catch (Exception ex)
                    {
                        message = "Lỗi trong quá trình cập nhật";
                    }
                }
            }
            if (isSuccess)
            {
                Response.Redirect("default.aspx?page=config");
            }
            else
            {
                //lblMessage.Visible = true;
                //lblMessage.CssClass = "error";
                //lblMessage.Text = message;

                //string message = "Lỗi trong quá trình cập nhật, lỗi: " + ex.Message;
                String cstext2 = "alert('" + message + "');";
                Page.ClientScript.RegisterStartupScript(this.GetType(), "alert", cstext2, true);
            }
        }