Exemplo n.º 1
0
        protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            string     un          = AspNetSecurityHelper.GetCurrentUserName;
            FAQManager _FAQManager = new FAQManager();

            if (e.CommandName == "DeleteUpdate")
            {
                string Id = e.CommandArgument.ToString();
                if (!String.IsNullOrEmpty(Id))
                {
                    int id = 0;
                    if (int.TryParse(Id, out id))
                    {
                        string         operation = (String)GetGlobalResourceObject("HCMResource", "Delete");
                        int            i         = 0;//_FAQManager.DeleteFAQ(id);
                        DAL.Entity.FAQ obj       = _FAQManager.GetFAQ(id);
                        if (obj != null)
                        {
                            obj.DeletedFlag     = true;
                            obj.LastUpdatedBy   = un;
                            obj.LastUpdatedDate = DateTime.Now;
                            i = _FAQManager.UpdateFAQ(obj);
                        }
                        if (i != 0)
                        {
                            ucAlertMessage.AlertMessage(String.Format((String)GetGlobalResourceObject("HCMResource", "OperationSuccess"), operation), "", Common.msgType.alertMessageSuccess);
                        }
                        else
                        {
                            ucAlertMessage.AlertMessage(String.Format((String)GetGlobalResourceObject("HCMResource", "OperationError"), operation), "", Common.msgType.alertMessageDanger);
                        }
                    }
                    FillData();
                }
            }
        }
Exemplo n.º 2
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            var user = AspNetSecurityHelper.currentAppUser;

            if (user != null)
            {
                FAQManager _FAQManager = new FAQManager();
                SSAManager _SSAManager = new SSAManager();

                DAL.Entity.FAQ obj = _FAQManager.GetFAQ(queryStringId);
                if (obj == null)
                {
                    obj = new DAL.Entity.FAQ();
                }

                obj.Question = txtQuestion.Text.Replace("\r\n", "<br/>");
                obj.Answer   = txtAnswer.Text.Replace("\r\n", "<br/>");

                if (user.UserTypeId == 2) // Supervisor
                {
                    if (user.UniversityId.HasValue)
                    {
                        var ssa = _SSAManager.GetSSAByUniversityId(user.UniversityId.Value);
                        //var ssa = _SSAManager.GetSSAByAdministratorId(user.Id);
                        if (ssa != null)
                        {
                            obj.SaudiStudentAssociationId = ssa.Id;
                        }
                    }
                }
                else // Administrator
                {
                    string SSA = ddlSSA.SelectedValue;
                    int    ssa = 0;
                    if (int.TryParse(SSA, out ssa) && ssa != 0)
                    {
                        obj.SaudiStudentAssociationId = ssa;
                    }
                }

                int i = 0;
                if (obj.Id == 0)
                {
                    obj.CreatedBy   = user.UserName;
                    obj.CreatedDate = DateTime.Now;
                    obj.DeletedFlag = false;
                    i               = _FAQManager.AddFAQ(obj);
                    Operation       = (String)GetGlobalResourceObject("HCMResource", "Add");
                    btnSave.Visible = false;
                }
                else
                {
                    obj.LastUpdatedBy   = user.UserName;
                    obj.LastUpdatedDate = DateTime.Now;
                    i         = _FAQManager.UpdateFAQ(obj);
                    Operation = (String)GetGlobalResourceObject("HCMResource", "Update");
                }
                if (i != 0)
                {
                    ucAlertMessage.AlertMessage(String.Format((String)GetGlobalResourceObject("HCMResource", "OperationSuccess"), Operation), "", Common.msgType.alertMessageSuccess);
                    FillData();
                }
                else
                {
                    ucAlertMessage.AlertMessage(String.Format((String)GetGlobalResourceObject("HCMResource", "OperationError"), Operation), "", Common.msgType.alertMessageDanger);
                }
            }
            else
            {
                Response.Redirect("/");
            }
        }