Esempio n. 1
0
 public int UpdateServiceInfo(DAL.Entity.ServiceInformation ServiceInfo)
 {
     try
     {
         _IServiceInfoRepository.Update(ServiceInfo);
         return(_IServiceInfoRepository.Save());
     }
     catch (Exception exception)
     {
         exception.Log();
         return(0);
     }
 }
Esempio n. 2
0
        protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            string             un = AspNetSecurityHelper.GetCurrentUserName;
            ServiceInfoManager _ServiceInfoManager = new ServiceInfoManager();

            if (e.CommandName == "DeleteUpdate")
            {
                string Id = e.CommandArgument.ToString();
                int    id = 0;
                if (int.TryParse(Id, out id))
                {
                    bool chk = _ServiceInfoManager.CheckCanDeleted(id);
                    if (chk)
                    {
                        string operation = (String)GetGlobalResourceObject("HCMResource", "Delete");
                        int    i         = 0;//_ServiceInfoManager.DeleteServiceInfo(id);
                        DAL.Entity.ServiceInformation obj = _ServiceInfoManager.GetServiceInfo(id);
                        if (obj != null)
                        {
                            obj.DeletedFlag     = true;
                            obj.LastUpdatedBy   = un;
                            obj.LastUpdatedDate = DateTime.Now;
                            i = _ServiceInfoManager.UpdateServiceInfo(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);
                        }
                    }
                    else
                    {
                        ucAlertMessage.AlertMessage((String)GetGlobalResourceObject("HCMResource", "CantDelete"), "", Common.msgType.alertMessageDanger);
                    }
                    FillData();
                }
            }
        }
Esempio n. 3
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            var user = AspNetSecurityHelper.currentAppUser;

            if (user != null)
            {
                ServiceInfoManager _ServiceInfoManager = new ServiceInfoManager();
                SSAManager         _SSAManager         = new SSAManager();

                DAL.Entity.ServiceInformation obj = _ServiceInfoManager.GetServiceInfo(queryStringId);
                if (obj == null)
                {
                    obj = new DAL.Entity.ServiceInformation();
                }

                obj.Title       = txtTitle.Text;
                obj.Description = txtDescription.Text.Replace("\r\n", "<br/>");
                obj.Section     = txtSection.Text;
                obj.Address     = txtAddress.Text.Replace("\r\n", "<br/>");

                string lat = ucLocation.Lat;
                string lng = ucLocation.Lng;

                if (!String.IsNullOrEmpty(lat) && !String.IsNullOrEmpty(lng))
                {
                    obj.Latitude  = lat;
                    obj.Longitude = lng;
                }

                int cat = 0;
                if (int.TryParse(ddlServiceCategory.SelectedValue, out cat) && cat != 0)
                {
                    obj.ServiceCategoryId = cat;
                }

                if (user.UserTypeId == 2) // Supervisor
                {
                    if (user.UniversityId.HasValue)
                    {
                        var ssa = _SSAManager.GetSSAByUniversityId(user.UniversityId.Value);
                        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               = _ServiceInfoManager.AddServiceInfo(obj);
                    Operation       = (String)GetGlobalResourceObject("HCMResource", "Add");
                    btnSave.Visible = false;
                }
                else
                {
                    obj.LastUpdatedBy   = user.UserName;
                    obj.LastUpdatedDate = DateTime.Now;
                    i         = _ServiceInfoManager.UpdateServiceInfo(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("/");
            }
        }