Пример #1
0
        public ReturnResult <TinhTrangVatLy> GetTinhTrangVatLyByID(int TinhTrangVatLyId)
        {
            var            result     = new ReturnResult <TinhTrangVatLy>();
            TinhTrangVatLy item       = new TinhTrangVatLy();
            DbProvider     dbProvider = new DbProvider();
            string         outCode    = String.Empty;
            string         outMessage = String.Empty;
            int            totalRows  = 0;

            try
            {
                dbProvider.SetQuery("TinhTrangVatLy_GET_BY_ID", CommandType.StoredProcedure)
                .SetParameter("TinhTrangVatLyID", SqlDbType.Int, TinhTrangVatLyId, ParameterDirection.Input)
                .SetParameter("ErrorCode", SqlDbType.NVarChar, DBNull.Value, 100, ParameterDirection.Output)
                .SetParameter("ErrorMessage", SqlDbType.NVarChar, DBNull.Value, 4000, ParameterDirection.Output)
                .GetSingle <TinhTrangVatLy>(out item)
                .Complete();
            }
            catch (Exception ex)
            {
                throw;
            }
            dbProvider.GetOutValue("ErrorCode", out outCode)
            .GetOutValue("ErrorMessage", out outMessage);

            return(new ReturnResult <TinhTrangVatLy>()
            {
                Item = item,
                ErrorCode = outCode,
                ErrorMessage = outMessage,
                TotalRows = totalRows
            });
        }
Пример #2
0
        public ReturnResult <TinhTrangVatLy> EditTinhTrangVatLy(TinhTrangVatLy TinhTrangVatLy)
        {
            ReturnResult <TinhTrangVatLy> result;
            DbProvider db;

            try
            {
                result = new ReturnResult <TinhTrangVatLy>();
                db     = new DbProvider();
                db.SetQuery("TinhTrangVatLy_EDIT", CommandType.StoredProcedure)
                .SetParameter("TinhTrangVatLyID", SqlDbType.Int, TinhTrangVatLy.TinhTrangVatLyId, ParameterDirection.Input)
                .SetParameter("TinhTrang", SqlDbType.NVarChar, TinhTrangVatLy.TinhTrang, 50, ParameterDirection.Input)
                .SetParameter("ErrorCode", SqlDbType.Int, DBNull.Value, ParameterDirection.Output)
                .SetParameter("ErrorMessage", SqlDbType.NVarChar, DBNull.Value, 4000, ParameterDirection.Output)
                .ExcuteNonQuery()
                .Complete();
                db.GetOutValue("ErrorCode", out string errorCode)
                .GetOutValue("ErrorMessage", out string errorMessage);
                if (errorCode.ToString() == "0")
                {
                    result.ErrorCode    = "0";
                    result.ErrorMessage = "";
                }
                else
                {
                    result.Failed(errorCode, errorMessage);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(result);
        }
Пример #3
0
        protected void btAddApprover_Click(object sender, EventArgs e)
        {
            try
            {
                if (!isUpdate())
                {
                    sec             = new TinhTrangVatLy();
                    sec.Name        = tbxName.Text;
                    sec.Description = tbxDescription.Text;
                }
                else
                {
                    sec.Name        = tbxName.Text;
                    sec.Description = tbxDescription.Text;
                }
                if (!isUpdate())
                {
                    if (validateSecurity(sec))
                    {
                        um.addTinhTrangVatLy(sec);
                        tbxDescription.Text = "";
                        tbxName.Text        = "";
                    }
                    else
                    {
                        Logger.logmessage(classobject, "btAddApprover_Click", "Validate fail 4 insert " + sec.Name);
                    }
                }
                else if (um.validateSecName4Update(sec.Name, sec.ID))
                {
                    um.updateTinhTrangVatLy(sec);
                    tbxDescription.Text = "";
                    tbxName.Text        = "";
                }
                else
                {
                    Logger.logmessage(classobject, "btAddApprover_Click", "Validate fail 4 update " + sec.Name);
                }

                Session[Su_TinhTrangVatLyLogic.SESSION_SEC_ID] = null;
                Response.Redirect("QLTinhTrangVatLy.aspx", false);
            }
            catch (Exception ex)
            {
                Logger.logmessage(classobject, "btAddApprover_Click", ex.Message + ex.StackTrace); Response.Redirect("~/ThongBaoLoi.aspx", false);
            }
        }
Пример #4
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                try
                {
                    if (Session[Su_TinhTrangVatLyLogic.SESSION_SEC_ID] != null)
                    {
                        btAddApprover.Text = "Cập nhật";
                        sec = um.getTinhTrangVatLy(Int32.Parse(Session[Su_TinhTrangVatLyLogic.SESSION_SEC_ID].ToString()));
                        if (sec != null)
                        {
                            tbxName.Text        = sec.Name;
                            tbxDescription.Text = sec.Description;
                        }
                    }
                    else
                    {
                        sec = new TinhTrangVatLy();
                    }

                    listAllSec();
                }
                catch (Exception ex)
                {
                    Logger.logmessage(classobject, "Page_Load", ex.Message + ex.StackTrace); Response.Redirect("~/ThongBaoLoi.aspx", false);
                }
            }
            else
            {
                string tId = "";
                if (Session[Su_TinhTrangVatLyLogic.SESSION_SEC_ID] != null)
                {
                    tId = Session[Su_TinhTrangVatLyLogic.SESSION_SEC_ID].ToString();
                    sec = new TinhTrangVatLy();
                    int iId = 0;
                    Int32.TryParse(tId, out iId);
                    sec.ID          = iId;
                    sec.Name        = tbxName.Text;
                    sec.Description = tbxDescription.Text;
                }
            }
        }
Пример #5
0
        protected bool validateSecurity(TinhTrangVatLy sec)
        {
            bool result = true;

            if (!um.validateSecName(sec.Name))
            {
                result = false;
                Response.Write("<script language='javascript'> { alert('Tên này đã có trong hệ thống. Xin chọn một tên khác');}</script>");
            }
            if (!um.validateSecNameNull(sec.Name))
            {
                result = false;
                Response.Write("<script language='javascript'> { alert('Tên không được phép để trống');}</script>");
            }
            if (!um.validateSecNameNull(sec.Description))
            {
                result = false;
                Response.Write("<script language='javascript'> { alert('Mô tả không được phép để trống');}</script>");
            }
            return(result);
        }
Пример #6
0
        public ReturnResult <TinhTrangVatLy> CreateTinhTrangVatLy(TinhTrangVatLy TinhTrangVatLy)
        {
            DbProvider provider     = new DbProvider();
            var        result       = new ReturnResult <TinhTrangVatLy>();
            string     outCode      = String.Empty;
            string     outMessage   = String.Empty;
            string     totalRecords = String.Empty;

            try
            {
                provider.SetQuery("TinhTrangVatLy_CREATE", System.Data.CommandType.StoredProcedure)
                .SetParameter("TinhTrang", SqlDbType.NVarChar, TinhTrangVatLy.TinhTrang, 50, ParameterDirection.Input)
                .SetParameter("ErrorCode", System.Data.SqlDbType.NVarChar, DBNull.Value, 100, System.Data.ParameterDirection.Output)
                .SetParameter("ErrorMessage", System.Data.SqlDbType.NVarChar, DBNull.Value, 4000, System.Data.ParameterDirection.Output)
                .GetSingle <TinhTrangVatLy>(out TinhTrangVatLy).Complete();

                provider.GetOutValue("ErrorCode", out outCode)
                .GetOutValue("ErrorMessage", out outMessage);

                if (outCode != "0" || outCode == "")
                {
                    result.ErrorCode    = outCode;
                    result.ErrorMessage = outMessage;
                }
                else
                {
                    result.Item         = TinhTrangVatLy;
                    result.ErrorCode    = outCode;
                    result.ErrorMessage = outMessage;
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return(result);
        }
Пример #7
0
        public ReturnResult <TinhTrangVatLy> DeleteTinhTrangVatLy(int id)
        {
            DbProvider     provider     = new DbProvider();
            var            result       = new ReturnResult <TinhTrangVatLy>();
            string         outCode      = String.Empty;
            string         outMessage   = String.Empty;
            string         totalRecords = String.Empty;
            TinhTrangVatLy item         = new TinhTrangVatLy();

            try
            {
                provider.SetQuery("TinhTrangVatLy_DELETE", CommandType.StoredProcedure)
                .SetParameter("TinhTrangVatLyID", SqlDbType.Int, id, ParameterDirection.Input)
                .SetParameter("ErrorCode", SqlDbType.NVarChar, DBNull.Value, 100, System.Data.ParameterDirection.Output)
                .SetParameter("ErrorMessage", SqlDbType.NVarChar, DBNull.Value, 4000, System.Data.ParameterDirection.Output)
                .ExcuteNonQuery().Complete();

                provider.GetOutValue("ErrorCode", out outCode)
                .GetOutValue("ErrorMessage", out outMessage);

                if (outCode != "0")
                {
                    result.Failed(outCode, outMessage);
                }
                else
                {
                    result.ErrorCode    = "0";
                    result.ErrorMessage = "";
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return(result);
        }
Пример #8
0
        public IActionResult UpdateTinhTrangVatLy(TinhTrangVatLy TinhTrangVatLy)
        {
            var result = tinhTranhVatLyBUS.EditTinhTrangVatLy(TinhTrangVatLy);

            return(Ok(result));
        }
Пример #9
0
 public ReturnResult <TinhTrangVatLy> EditTinhTrangVatLy(TinhTrangVatLy TinhTrangVatLy)
 {
     return(tinhTranVatLyDAL.EditTinhTrangVatLy(TinhTrangVatLy));
 }
Пример #10
0
 public ReturnResult <TinhTrangVatLy> CreateTinhTrangVatLy(TinhTrangVatLy TinhTrangVatLy)
 {
     return(tinhTranVatLyDAL.CreateTinhTrangVatLy(TinhTrangVatLy));
 }