コード例 #1
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                FacultyMaster objFacultyCheck = db.FacultyMasters.Where(aa => aa.F_AYN == "Y" && aa.F_USERNAME == txtUserName.Text.Trim()).FirstOrDefault();

                if (objFacultyCheck != null)
                {
                    lblErrMsg.Text = "Username already exits, Please try another name";
                }
                else
                {
                    FacultyMaster objNewFaclty = new FacultyMaster();

                    objNewFaclty.F_USERNAME    = txtUserName.Text.Trim();
                    objNewFaclty.F_PWD         = txtPwd.Text.Trim();
                    objNewFaclty.F_NAME        = txtFacltyName.Text.Trim();
                    objNewFaclty.F_DESCRIPTION = txtDescription.Text.Trim();
                    objNewFaclty.F_EMAIL       = txtEmail.Text.Trim();
                    objNewFaclty.F_PHNUM       = txtPhNum.Text.Trim();
                    objNewFaclty.F_ADDRESS     = txtAddress.Text.Trim();

                    objNewFaclty.F_AYN = "Y";
                    objNewFaclty.CDATE = DateTime.Now.ToString("yyyyMMddHHmmss");
                    objNewFaclty.CUSER = "******";

                    db.FacultyMasters.Add(objNewFaclty);

                    User objUser = new Models.User();

                    objUser.U_USERNAME  = txtUserName.Text.Trim();
                    objUser.U_PASSWORD  = txtPwd.Text.Trim();
                    objUser.U_FIRSTNAME = txtFacltyName.Text.Trim();
                    objUser.U_LASTNAME  = txtDescription.Text.Trim();
                    objUser.U_EMAIL     = txtEmail.Text.Trim();
                    objUser.U_PHNUM     = txtPhNum.Text.Trim();
                    objUser.U_ADDRESS   = txtAddress.Text.Trim();
                    objUser.U_ROLE_ID   = 2;
                    objUser.U_ROLE_NAME = "Faculty";

                    objUser.U_ISACTIVE = "Y";
                    objUser.CDATE      = DateTime.Now.ToString("yyyyMMddHHmmss");
                    objUser.CUSER      = "******";

                    db.Users.Add(objUser);

                    db.SaveChanges();
                    Response.Redirect("~/Admin/FacultyList.aspx");
                }
            }
            catch (Exception ee)
            {
            }
        }
コード例 #2
0
 private void LoadAllLoginFaculty()
 {
     try
     {
         objLoginFaculty = db.FacultyMasters.Where(aa => aa.F_AYN == "Y" && aa.F_USERNAME == objLoginUser.U_USERNAME).FirstOrDefault();
         LoadAllFacultyCourses();
     }
     catch (Exception ee)
     {
     }
 }
コード例 #3
0
        public async Task <IActionResult> UpdateFacultyMaster([FromBody] FacultyMaster facultyMaster)
        {
            try
            {
                facultyMaster.ModifiedBy   = "Admin";
                facultyMaster.ModifiedDate = DateTime.Now;

                db.Entry(facultyMaster).State = Microsoft.EntityFrameworkCore.EntityState.Modified;
                db.SaveChanges();
                return(Ok(facultyMaster));
            }
            catch (Exception ex)
            {
                return(BadRequest());
            }
        }
コード例 #4
0
 public async Task <IActionResult> CreateFacultyMaster([FromBody] FacultyMaster facultyMaster)
 {
     try
     {
         //bannerMaster.EnquiryID = 0;
         facultyMaster.CreatedBy    = "Admin";
         facultyMaster.CreatedDate  = DateTime.Now;
         facultyMaster.ModifiedBy   = "Admin";
         facultyMaster.ModifiedDate = DateTime.Now;
         facultyMaster.Active       = true;
         db.facultyMaster.Add(facultyMaster);
         db.SaveChanges();
         return(Ok(facultyMaster));
     }
     catch (Exception ex)
     {
         return(BadRequest());
     }
 }
コード例 #5
0
        protected void submitButton_Click(object sender, EventArgs e)
        {
            try
            {
                var objCheckUser = db.Users.Where(aa => aa.U_ISACTIVE == "Y" && aa.U_USERNAME == txtUserName.Text.Trim()).FirstOrDefault();

                if (objCheckUser == null)
                {
                    User objUser = new User();

                    objUser.U_USERNAME  = txtUserName.Text.Trim();
                    objUser.U_PASSWORD  = txtPwd.Text.Trim();
                    objUser.U_FIRSTNAME = txtFirstName.Text.Trim();
                    objUser.U_LASTNAME  = txtLastName.Text.Trim();
                    objUser.U_EMAIL     = txtEmail.Text.Trim();
                    objUser.U_PHNUM     = txtPhNum.Text.Trim();
                    objUser.U_ADDRESS   = txtAddress.Text.Trim();
                    objUser.U_ISACTIVE  = "Y";
                    objUser.CUSER       = txtUserName.Text.Trim();
                    objUser.CDATE       = DateTime.Now.ToString("yyyyMMddHHmmss");
                    objUser.U_ROLE_ID   = 2;
                    objUser.U_ROLE_NAME = "Faculty";

                    db.Users.Add(objUser);

                    FacultyMaster objNewFaclty = new FacultyMaster();

                    objNewFaclty.F_USERNAME    = txtUserName.Text.Trim();
                    objNewFaclty.F_PWD         = txtPwd.Text.Trim();
                    objNewFaclty.F_NAME        = txtFirstName.Text.Trim();
                    objNewFaclty.F_DESCRIPTION = txtLastName.Text.Trim();
                    objNewFaclty.F_EMAIL       = txtEmail.Text.Trim();
                    objNewFaclty.F_PHNUM       = txtPhNum.Text.Trim();
                    objNewFaclty.F_ADDRESS     = txtAddress.Text.Trim();

                    objNewFaclty.F_AYN = "Y";
                    objNewFaclty.CDATE = DateTime.Now.ToString("yyyyMMddHHmmss");
                    objNewFaclty.CUSER = "******";

                    db.FacultyMasters.Add(objNewFaclty);

                    try
                    {
                        db.SaveChanges();
                    }
                    catch (DbEntityValidationException ex)
                    {
                        foreach (var eve in ex.EntityValidationErrors)
                        {
                            resultLabel.Text = "Entity of type \"{0}\" in state \"{1}\" has the following validation errors:" + eve.Entry.Entity.GetType().Name + "," + eve.Entry.State;
                            foreach (var ve in eve.ValidationErrors)
                            {
                                resultLabel.Text = "- Property: \"{0}\", Error: \"{1}\"" + ve.PropertyName + " , " + ve.ErrorMessage;
                            }
                        }
                    }

                    Session["role"] = "2";
                    Response.Redirect("~/frmlogin.aspx");
                }
                else
                {
                    resultLabel.Text = "Username already exits....! Please try some other username";
                    txtUserName.Focus();
                }
            }
            catch (Exception ee)
            {
            }
        }