Esempio n. 1
0
        public int Save(Models.MUsers model)
        {
            Common.Logger l         = new Common.Logger();
            string        ClassName = "CUsers";

            try
            {
                var query = from a in obj.Users where a.name == model.name select a.name;
                if (query.Count() == 0)
                {
                    DB.User bs = new DB.User();

                    bs.name     = model.name;
                    bs.password = model.password;
                    bs.Approved = "0";
                    bs.eDate    = Convert.ToDateTime(model.eDate);

                    l.Print(ClassName, Common.LogPointer.Info.ToString(), "Model Values id[" + model.id + "] name[" + model.name + "] password[" + model.password + "] eDate[" + model.eDate + "]");
                    obj.Users.InsertOnSubmit(bs);
                    obj.SubmitChanges();
                    l.Print(ClassName, Common.LogPointer.Info.ToString(), "Record Inserted Successfully");
                    return(1);
                }
                else
                {
                    return(2);
                }
            }
            catch (Exception ex)
            {
                l.Print(ClassName, Common.LogPointer.Error.ToString(), ex.ToString());
                return(-1);
            }
        }
Esempio n. 2
0
        public int Update(Models.MUsers model)
        {
            Common.Logger l         = new Common.Logger();
            string        ClassName = "CUsers";

            try
            {
                var query = from o in obj.Users where Convert.ToString(o.id) == model.id select o;

                foreach (var item in query)
                {
                    item.name     = model.name;
                    item.password = model.password;
                    item.Approved = item.Approved;
                    item.eDate    = Convert.ToDateTime(model.eDate);
                }
                l.Print(ClassName, Common.LogPointer.Info.ToString(), "Model Values id[" + model.id + "] name[" + model.name + "] password[" + model.password + "] eDate[" + model.eDate + "]");
                obj.SubmitChanges();
                l.Print(ClassName, Common.LogPointer.Info.ToString(), "Record Updated Successfully");
                return(1);
            }
            catch (Exception ex)
            {
                l.Print(ClassName, Common.LogPointer.Error.ToString(), ex.ToString());
                return(-1);
            }
        }
Esempio n. 3
0
        protected void btnLogin_Click(object sender, EventArgs e)
        {
            Classes.CUsers cu     = new Classes.CUsers();
            int            UserId = cu.GetUserIdByName(txtLoginUserId.Text);

            Models.MUsers mu          = new Models.MUsers();
            string        WareHouseId = string.Empty;

            mu.name     = txtLoginUserId.Text;
            mu.password = txtLoginPassword.Text;
            int retVal = cu.ValidateUser(mu);

            if (retVal == -1)
            {
                lblShow.Text = "Invalid User ID or Password";
            }
            else if (retVal == -2)
            {
                Response.Redirect("~/Pages/SetFiscalYear.aspx");
            }
            else if (retVal == 1)
            {
                Session["User"]       = txtLoginUserId.Text;
                Session["FiscalYear"] = retVal;
                Session["WareHouse"]  = ReturnWareHouseId(UserId.ToString());
            }
        }
Esempio n. 4
0
        public List <Models.MUsers> GetAllbyid(int id)
        {
            List <Models.MUsers> model = new List <Models.MUsers>();
            var query = from o in obj.Users where (o.id) == id select o;

            foreach (var item in query)
            {
                Models.MUsers m = new Models.MUsers();
                m.id       = Convert.ToString(item.id);
                m.name     = item.name;
                m.password = item.password;
                m.eDate    = Convert.ToString(item.eDate);
                model.Add(m);
            }

            return(model);
        }
Esempio n. 5
0
        public List <Models.MUsers> GetApprovedUsers()
        {
            List <Models.MUsers> model = new List <Models.MUsers>();
            var query = from o in obj.Users where o.Approved == "1" select o;

            foreach (var item in query)
            {
                Models.MUsers m = new Models.MUsers();
                m.id       = Convert.ToString(item.id);
                m.name     = item.name;
                m.password = item.password;
                m.Approved = item.Approved;
                m.eDate    = Convert.ToString(item.eDate);
                model.Add(m);
            }

            return(model);
        }
Esempio n. 6
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            Models.MUsers mu = new Models.MUsers();
            mu.name     = txtuserID.Text;
            mu.password = txtPassword.Text;
            Classes.CUsers cu = new Classes.CUsers();

            if (cu.Save(mu) < 0)
            {
                ShowFailMessage();
            }
            else if (cu.Save(mu) == 2)
            {
                lbluser.Text = "UserName [" + txtuserID.Text + "] Already exists";
            }
            else
            {
                ShowSuccessMessage();
            }
        }
Esempio n. 7
0
        public int ValidateUser(Models.MUsers mu)
        {
            CFiscalYear cf           = new CFiscalYear();
            int         fiscalYearId = cf.CheckFiscalYear();

            if (fiscalYearId < 0)
            {
                return(-2);
            }
            else
            {
                var query  = (from a in obj.Users where a.name == mu.name select a.password).FirstOrDefault();
                var query1 = (from a in obj.Users where a.name == mu.name select a.Approved).FirstOrDefault();
                if (query == mu.password && query1.ToString() == "1")
                {
                    return(fiscalYearId);
                }
                else
                {
                    return(-1);
                }
            }
        }