public ActionResult Company()
        {
            try
            {
                GetPagePermissionResult objPermission = Functions.CheckPagePermission(PageMaster.Company);
                if (!objPermission.IsActive)
                {
                    return(this.RedirectToAction("Logout", "Home"));
                }

                ClsCompany objClsCompany = this.objiClsCompany as ClsCompany;
                long       lgUserId      = 0;
                if (this.Request.QueryString.Count > 0)
                {
                    if (this.Request.QueryString["iFrame"] != null)
                    {
                        if (!objPermission.Add_Right)
                        {
                            return(this.RedirectToAction("PermissionRedirectPage", "Home"));
                        }

                        objClsCompany.hdniFrame = true;
                    }
                    else
                    {
                        if (!objPermission.Edit_Right || string.IsNullOrEmpty(this.Request.QueryString.ToString().Decode()))
                        {
                            return(this.RedirectToAction("PermissionRedirectPage", "Home"));
                        }

                        lgUserId      = this.Request.QueryString.ToString().Decode().longSafe();
                        objClsCompany = this.objiClsCompany.GetCompanyByCompanyId(lgUserId);
                    }
                }
                else
                {
                    if (!objPermission.Add_Right)
                    {
                        return(this.RedirectToAction("PermissionRedirectPage", "Home"));
                    }
                }

                #region Menu Access
                Controllers.BaseController baseController = new Controllers.BaseController();
                this.ViewData = baseController.MenuAccessPermissions(objPermission);
                #endregion
                this.ViewData["UserRoleID"] = mySession.Current.RoleId;

                this.BindDropDownListForCompany(objClsCompany, true);
                return(this.View(objClsCompany));
            }
            catch (Exception ex)
            {
                Functions.Write(ex, System.Reflection.MethodBase.GetCurrentMethod().Name, PageMaster.Company, mySession.Current.UserId);
                return(this.View());
            }
        }
        private string ValidateCompany(ClsCompany objCompany)
        {
            try
            {
                string strErrorMsg = string.Empty;
                if (string.IsNullOrEmpty(objCompany.strShortName))
                {
                    strErrorMsg += Functions.AlertMessage("ShortName", MessageType.InputRequired) + "<br/>";
                }

                if (string.IsNullOrEmpty(objCompany.strFullName))
                {
                    strErrorMsg += Functions.AlertMessage("Full Name", MessageType.InputRequired) + "<br/>";
                }

                if (string.IsNullOrEmpty(objCompany.strAddress1))
                {
                    strErrorMsg += Functions.AlertMessage("Address", MessageType.InputRequired) + "<br/>";
                }
                if (string.IsNullOrEmpty(Convert.ToString(objCompany.intVat)))
                {
                    strErrorMsg += Functions.AlertMessage("Vat", MessageType.InputRequired) + "<br/>";
                }
                if (string.IsNullOrEmpty(objCompany.strEmail))
                {
                    strErrorMsg += Functions.AlertMessage("Email Id", MessageType.InputRequired) + "<br/>";
                }
                if (string.IsNullOrEmpty(objCompany.strPerson))
                {
                    strErrorMsg += Functions.AlertMessage("Person", MessageType.InputRequired) + "<br/>";
                }
                if (string.IsNullOrEmpty(objCompany.strContact))
                {
                    strErrorMsg += Functions.AlertMessage("Contact", MessageType.InputRequired) + "<br/>";
                }
                if (string.IsNullOrEmpty(objCompany.strAdminUserIds))
                {
                    strErrorMsg += Functions.AlertMessage("AdminUserIds", MessageType.InputRequired) + "<br/>";
                }

                return(strErrorMsg);
            }
            catch (Exception ex)
            {
                Functions.Write(ex, System.Reflection.MethodBase.GetCurrentMethod().Name, PageMaster.Company, mySession.Current.UserId);
                return(string.Empty);
            }
        }
 public void BindDropDownListForCompany(ClsCompany objClsCompany, bool blBindDropDownFromDb)
 {
     try
     {
         if (blBindDropDownFromDb)
         {
             objClsCompany.lstAdminuser = this.objiClsUser.GetAllAdminUserForDropDown().ToList();
         }
         else
         {
             objClsCompany.lstAdminuser = new List <SelectListItem>();
         }
     }
     catch (Exception ex)
     {
         Functions.Write(ex, System.Reflection.MethodBase.GetCurrentMethod().Name, PageMaster.Company);
     }
 }
        public ActionResult Company(ClsCompany objCompany)
        {
            try
            {
                objCompany.strAdminUserIds = objCompany.hdnstrAdminUserIds;
                ////bool blEmailFlag = false;
                GetPagePermissionResult objPermission = Functions.CheckPagePermission(PageMaster.Company);
                if (!objPermission.IsActive)
                {
                    return(this.RedirectToAction("Logout", "Home"));
                }

                if (objCompany.lgId == 0)
                {
                    if (!objPermission.Add_Right)
                    {
                        return(this.RedirectToAction("PermissionRedirectPage", "Home"));
                    }
                }
                else
                {
                    if (!objPermission.Edit_Right)
                    {
                        return(this.RedirectToAction("PermissionRedirectPage", "Home"));
                    }
                }

                if (objCompany.hdniFrame)
                {
                    this.ViewData["iFrame"] = "iFrame";
                }

                bool blExists = this.objiClsCompany.IsCompanyExists(objCompany.lgId, objCompany.strShortName);
                if (blExists)
                {
                    this.ViewData["Success"] = "0";
                    this.ViewData["Message"] = Functions.AlertMessage("Company", MessageType.AlreadyExist);
                }
                else
                {
                    string strErrorMsg = this.ValidateCompany(objCompany);
                    if (!string.IsNullOrEmpty(strErrorMsg))
                    {
                        this.ViewData["Success"] = "0";
                        this.ViewData["Message"] = strErrorMsg;
                    }
                    else
                    {
                        long resultId = this.objiClsCompany.SaveCompany(objCompany);
                        if (resultId > 0)
                        {
                            this.ViewData["Success"] = "1";
                            this.ViewData["Message"] = Functions.AlertMessage("Company", MessageType.Success);
                            this.BindDropDownListForCompany(objCompany, true);
                            return(this.View(objCompany));
                        }
                        else
                        {
                            this.ViewData["Success"] = "0";
                            this.ViewData["Message"] = Functions.AlertMessage("Company", MessageType.Fail);
                        }
                    }
                }
                this.BindDropDownListForCompany(objCompany, true);
                return(this.View(objCompany));
            }
            catch (Exception ex)
            {
                this.ViewData["Success"] = "0";
                this.ViewData["Message"] = Functions.AlertMessage("Company", MessageType.Fail);
                Functions.Write(ex, System.Reflection.MethodBase.GetCurrentMethod().Name, PageMaster.Company, mySession.Current.UserId);
                return(this.View(objCompany));
            }
        }