Exemple #1
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            if (FieldValidation() == false)
            {
                return;
            }
            IReason ReasonManager;

            try
            {
                if (Request.QueryString["name"] == "Add")
                {
                    ReasonManager = (IReason)ObjectFactory.CreateInstance("BusinessProcess.Administration.BReason, BusinessProcess.Administration");
                    int ReasonId = ReasonManager.SaveNewReason(txtReasonName.Text, Convert.ToInt32(ddCategory.SelectedValue), Convert.ToInt32(txtSRNo.Text), 1);
                    if (ReasonId == 0)
                    {
                        IQCareMsgBox.Show("ReasonExists", this);
                        return;
                    }
                    else
                    {
                        IQCareMsgBox.Show("ReasonSave", this);
                        clear_fields();
                    }
                }
                else
                {
                    int ReasonId;
                    ReasonId = Convert.ToInt32(Request.QueryString["ReasonId"]);

                    ReasonManager = (IReason)ObjectFactory.CreateInstance("BusinessProcess.Administration.BReason, BusinessProcess.Administration");
                    ReasonId      = ReasonManager.UpdateReason(ReasonId, (txtReasonName.Text.ToUpper()), Convert.ToInt32(ddCategory.SelectedValue), Convert.ToInt32(txtSRNo.Text), 1, Convert.ToInt32(this.ddStatus.SelectedValue));
                }
            }
            catch (Exception err)
            {
                MsgBuilder theBuilder = new MsgBuilder();
                theBuilder.DataElements["MessageText"] = err.Message.ToString();
                IQCareMsgBox.Show("#C1", this);
                return;
            }
            finally
            {
                ReasonManager = null;
            }
        }
        public string UpdateData(string id, string title, string remark)
        {
            if (Session[Util.ProjectConfig.ADMINUSER] == null)
            {
                return("");
            }

            Reason re = new Reason();

            re.ID     = Convert.ToInt32(id);
            re.Title  = title;
            re.Remark = remark;
            try
            {
                if (ReasonManager.UpdateReason(re))
                {
                    return("success");
                }
                return("error");
            }
            catch (Exception ex) {
                return("error");
            }
        }