Ejemplo n.º 1
0
        public static int EmailExist(String EmailID)
        {
            try
            {

                int result = 0;
                using (var ctx = new ExponentPortalEntities())
                {
                    var _objuserdetail = (from data in ctx.MSTR_User
                                          where data.EmailId == EmailID


                                          select data);

                    result = _objuserdetail.Count();
                }

                return result;

            }
            catch (Exception ex)
            {
                Util.ErrorHandler(ex);
                System.Web.HttpContext.Current.Response.Write("<script>alert('Please Check Database Connection');</script>");
                return -1;
            }
        }
Ejemplo n.º 2
0
    public bool isValidated(int ThisCheckListID, int DroneID) {
      String SQL;
      String sFieldValue;
      Decimal FieldValue = 0;
      bool Validated = true;
      SQL = "SELECT FieldValue, FieldNote FROM [DroneCheckListItem] WHERE\n" +
        "  [DroneCheckListID] = " + ThisCheckListID + " AND\n" +
        "  [DroneCheckListItemID] = " + ID;
      var Result = Util.getDBRow(SQL);

      sFieldValue = Result["FieldValue"].ToString();
      this.FieldNote = Result["FieldNote"].ToString();
      this.FieldValue = sFieldValue;
      try {
        FieldValue = Convert.ToDecimal(sFieldValue);
      }  catch(Exception ex) {
        Util.ErrorHandler(ex);
        //error in parsing data. set to zero
        FieldValue = 0;
      }

      SQL = "SELECT MinValue, MaxValue FROM [DroneCheckListValidation] WHERE \n" +
        "  [DroneID]= " + DroneID + " AND\n" +
        "  [DroneCheckListID] = " + CheckListID + " AND\n" +
        "  [DroneCheckListItemID] = " + ID;

      Result = Util.getDBRow(SQL);
      if ((bool)Result["hasRows"]) {
        Decimal MinValue = (Decimal)Result["MinValue"];
        Decimal MaxValue = (Decimal)Result["MaxValue"];
        if (MinValue > 0 && MaxValue > 0 && FieldValue >= MinValue && FieldValue <= MaxValue) {
          Validated = true;
        } else if (MinValue == 0 && MaxValue == 0) {
          Validated = true;
        } else {
          Validated = false;
        }
      }

      this.isValid = Validated;
      return Validated;

    }//function isValidated
Ejemplo n.º 3
0
    public static int UserIsActive(String UserName, String Password)
    {
        try
        {
            string PasswordCrypto = Util.GetEncryptedPassword(Password);
            int result = 0;
                
            using (var ctx = new ExponentPortalEntities())
            {
                var _objuserdetail = (from data in ctx.MSTR_User
                                      where (data.UserName == UserName
                                      && data.Password == PasswordCrypto)
                                      select data.IsActive).ToList();
                    if (_objuserdetail.Count > 0)
                    {
                        string isactive = _objuserdetail[0].ToString();
                        if (isactive == "True")
                        {
                            result = 1;
                        }
                        else
                        {
                            result = 0;
                        }
                    }
                    else
                    {
                        result = 0;
                    }
            }
            return result;

        }
        catch (Exception ex)
        {
            Util.ErrorHandler(ex);
            System.Web.HttpContext.Current.Response.Write("<script>alert('Please Check Database Connection');</script>");
            return -1;
        }
   }
Ejemplo n.º 4
0
    public static IList<MenuModel> BuildMenu() {

      IList<MenuModel> mmList = new List<MenuModel>();
      try {

        var menu_items = db.MSTR_Menu;
        var UserId = System.Web.HttpContext.Current.Session["UserId"] == null ? 0 : System.Web.HttpContext.Current.Session["UserId"];


        String SQL = "select * from MSTR_Menu where Visible=1 and  MenuId" +
            " in(select b.MenuId from  MSTR_Profile a left join   M2M_ProfileMenu b" +
             "  on a.ProfileId = b.ProfileId left join MSTR_User c on b.ProfileId = c.UserProfileId" +
             "   where c.UserId =" + UserId + ") order by SortOrder asc ";
        var MenuName = db.Database.SqlQuery<MSTR_Menu>(SQL);


        foreach (MSTR_Menu mnu in MenuName) {
          MenuModel model = new MenuModel();
          model.Id = mnu.MenuId;
          model.Name = mnu.MenuName;
          model.ParentId = mnu.ParentId.GetValueOrDefault();
          model.SortOrder = mnu.SortOrder.GetValueOrDefault();
          model.PageUrl = mnu.PageUrl;

          mmList.Add(model);

          if(mnu.MenuName == "Home") {
            AddCmsMenuTo(mmList, mnu.MenuId);
          }
        }

      } catch (Exception ex) {
        Util.ErrorHandler(ex);
      }
      return mmList;
    }