Пример #1
0
        private void CancButton_Click(object sender, EventArgs e)
        {
            if (IsCubicleOnEdit)
            {
                ResetButton.Visible = false;
                SaveButton.Visible  = false;
                CancButton.Visible  = false;
                IsCubicleOnEdit     = false;


                //ArrowKeys used to resize the cubicle
                UPArrow.Visible    = false;
                LeftArrow.Visible  = false;
                resetSize.Visible  = false;
                RightArrow.Visible = false;
                DownArrow.Visible  = false;

                for (int i = 0; i < 6; i++)
                {
                    l[i].Visible = false;
                    l[i].Dispose();
                }

                C_Name.Dispose();
                CubNo.Dispose();
                EmpName.Dispose();
                EmpSno.Dispose();
                C_State.Dispose();
                Other.Dispose();

                S = -1;
            }
            else if (IsResourceOnEdit)
            {
                IsResourceOnEdit    = false;
                ResetButton.Visible = false;
                SaveButton.Visible  = false;
                CancButton.Visible  = false;

                for (int i = 0; i < 7; i++)
                {
                    l[i].Visible = false;
                    l[i].Dispose();
                }

                AssEmpNo.Dispose();
                AssCubNo.Dispose();
                ResNo.Dispose();
                ResType.Dispose();
                ResState.Dispose();
                DateOfIssue.Dispose();
                OtherInfo.Dispose();

                P = -1;
            }
        }
Пример #2
0
 private void btnOK_Click(object sender, EventArgs e)
 {
     //проводим авторизацию пользователя при нужной роли и правильном пароле
     if (cmbRole.SelectedItem.Equals("manager"))  //проверка выбранной роли
     {
         foreach (var item in UsersRole.UserManager)
         {
             if (item.UserName.Equals(txtName.Text) && item.UserPassword.Equals(txtPassword.Text))//проверка верного пароля
             {
                 EmpName en  = s => s = txtName.Text;
                 Manager man = new Manager();
                 man.Show();
                 return;
             }
         }
         MessageBox.Show("неверный пароль или логин");
         txtPassword.Clear();
         txtName.Clear();
     }
     else if (cmbRole.SelectedItem.Equals("saler"))//проверка выбранной роли
     {
         foreach (var item in UsersRole.UserSaler)
         {
             if (item.UserPassword.Equals(txtPassword.Text) && item.UserName.Equals(txtName.Text))//проверка верного пароля
             {
                 EmpName en  = s => s = txtName.Text;
                 Saler   sal = new Saler();
                 sal.Show();
                 //Saler s =new Saler();
                 //s.Show();
                 return;
             }
         }
         MessageBox.Show("неверный пароль или логин");
         txtPassword.Clear();
         txtName.Clear();
     }
     else if (cmbRole.SelectedItem.Equals("owner"))//проверка выбранной роли
     {
         foreach (var item in UsersRole.UserOwner)
         {
             if (item.UserPassword.Equals(txtPassword.Text) && item.UserName.Equals(txtName.Text))//проверка верного пароля
             {
                 EmpName en  = s => s = txtName.Text;
                 Owner   sal = new Owner();
                 sal.Show();
                 return;
             }
         }
         MessageBox.Show("неверный пароль или логин");
         txtPassword.Clear();
         txtName.Clear();
     }
 }
        public void load()
        {
            EmpName.Clear();
            if (Program.con.State == ConnectionState.Closed)
            {
                Program.con.Open();
            }
            string        query = "select id from login where post = 'o'";
            SqlCommand    cmd   = new SqlCommand(query, Program.con);
            SqlDataReader sdr   = cmd.ExecuteReader();

            while (sdr.Read())
            {
                EmpName.AddItem("" + sdr[0]);
            }

            sdr.Close();
            cmd.Dispose();
        }
Пример #4
0
 public override int GetHashCode()
 {
     return(EmpName.GetHashCode());//Gets the ID which determines whether 2 objects are of the same kind.
 }
Пример #5
0
        public HttpResponseMessage GetSearchResult(object data)
        {
            var db = DbUtils.GetDBConnection();

            db.Connection.Open();
            IEnumerable <IDictionary <string, object> > response = null;
            var    jsonData = JsonConvert.SerializeObject(data);
            var    dictJson = JsonConvert.DeserializeObject <Dictionary <string, object> >(jsonData);
            object actionObject;

            dictJson.TryGetValue("actionName", out actionObject);
            string Action = actionObject.ToString();

            string input_queryapi = "";

            object userName;

            dictJson.TryGetValue("queried_by_username", out userName);


            if (Action.Equals("GetTableSchema"))
            {
                object tableName;
                dictJson.TryGetValue("TableName", out tableName);
                input_queryapi = tableName.ToString();
                response       = db.Query("INFORMATION_SCHEMA.COLUMNS").Select("COLUMN_NAME").WhereRaw("TABLE_NAME  = ?", tableName).Get().Cast <IDictionary <string, object> >();
                return(Request.CreateResponse(HttpStatusCode.OK, response));
            }
            if (Action.Equals("GetInstructorByName"))
            {
                object empName;
                dictJson.TryGetValue("EmpName", out empName);
                input_queryapi = empName.ToString();
                response       = db.Query("Employee").WhereRaw("lower(EmpName) = ?", empName).Get().Cast <IDictionary <string, object> >();
                //response = db.Query("Employee").WhereRaw("lower(EmpName) = ?", "dr. abdul aziz").Get().Cast<IDictionary<string, object>>();
            }
            else if (Action.Equals("GetInstructorByEmail"))
            {
                object email;
                dictJson.TryGetValue("Email", out email);
                input_queryapi = email.ToString();
                response       = db.Query("Employee").WhereRaw("lower(Email) = ?", email).Get().Cast <IDictionary <string, object> >();
            }
            else if (Action.Equals("GetInstructorByRank"))
            {
                object designationTitle;
                dictJson.TryGetValue("DesignationTitle", out designationTitle);
                input_queryapi = designationTitle.ToString();
                response       = db.Query("Employee").Join("Designation", "Employee.DesignationID", "Designation.DesignationID").Where("DesignationTitle", designationTitle).Get().Cast <IDictionary <string, object> >(); //get product by id=1
            }
            else if (Action.Equals("GetInstructorByDepartment"))
            {
                object departmentID;
                dictJson.TryGetValue("DepartmentID", out departmentID);
                input_queryapi = departmentID.ToString();
                response       = db.Query("Employee").Join("Department", "Employee.DepartmentID", "Department.DepartmentID").Where("Department.DepartmentID", departmentID).Get().Cast <IDictionary <string, object> >(); //get product by id=1
            }
            else if (Action.Equals("GetInstructorByNameStartsWith"))
            {
                object startNamePrefix;
                dictJson.TryGetValue("EmpName", out startNamePrefix);
                string prefixString = startNamePrefix.ToString() + "%";
                input_queryapi = startNamePrefix.ToString();
                response       = db.Query("Employee").WhereLike("EmpName", prefixString).Get().Cast <IDictionary <string, object> >(); //get product by id=1
            }
            else if (Action.Equals("GetInstructorByNameContains"))
            {
                object startNamePrefix;
                dictJson.TryGetValue("EmpName", out startNamePrefix);
                string prefixString = "%" + startNamePrefix.ToString() + "%";
                input_queryapi = startNamePrefix.ToString();
                response       = db.Query("Employee").WhereLike("EmpName", prefixString).Get().Cast <IDictionary <string, object> >(); //get product by id=1
            }
            else if (Action.Equals("GetInstructorByCourseName"))
            {
                object courseName;
                dictJson.TryGetValue("CourseName", out courseName);
                input_queryapi = courseName.ToString();
                response       = db.Query("Employee").Join("CourseFaculty", "Employee.EmpID", "CourseFaculty.EmpID").Join("CourseOffered", "CourseOffered.CourseOfferedID", "CourseFaculty.CourseOfferedID").Join("Course", "CourseOffered.CourseID", "Course.CourseID").Where("CourseName", courseName).Get().Cast <IDictionary <string, object> >(); //get product by id=1
            }
            else if (Action.Equals("GetInstructorByCourseCode"))
            {
                object courseCode;
                dictJson.TryGetValue("CourseCode", out courseCode);
                input_queryapi = courseCode.ToString();
                response       = db.Query("Employee").Join("CourseFaculty", "Employee.EmpID", "CourseFaculty.EmpID").Join("CourseOffered", "CourseOffered.CourseOfferedID", "CourseFaculty.CourseOfferedID").Join("Course", "CourseOffered.CourseID", "Course.CourseID").Where("CourseCode", courseCode).Get().Cast <IDictionary <string, object> >(); //get product by id=1
            }
            else if (Action.Equals("GetCoursesTaughtByASpecificInstructor"))
            {
                object EmpName;
                dictJson.TryGetValue("EmpName", out EmpName);
                input_queryapi = EmpName.ToString();
                response       = db.Query("Semester").Select("CourseName").Join("CourseOffered", "Semester.SemesterID", "CourseOffered.SemesterID").Join("Course", "Course.CourseID", "CourseOffered.CourseID")
                                 .Join("CourseFaculty", "CourseFaculty.CourseOfferedID", "CourseOffered.CourseOfferedID")
                                 .Join("Employee", "Employee.EmpID", "CourseFaculty.EmpID")
                                 .Where("EmpName", EmpName).Get().Cast <IDictionary <string, object> >(); //get product by id=1
            }
            else if (Action.Equals("GetCoursesTaughtByAInstructorInAParticularSemester"))
            {
                object semesterName;
                object empName;
                dictJson.TryGetValue("EmpName", out empName);
                dictJson.TryGetValue("SemesterName", out semesterName);
                input_queryapi = empName.ToString() + " " + semesterName.ToString();
                response       = db.Query("Semester").Join("CourseOffered", "Semester.SemesterID", "CourseOffered.SemesterID").Join("Course", "Course.CourseID", "CourseOffered.CourseID")
                                 .Join("CourseFaculty", "CourseFaculty.CourseOfferedID", "CourseOffered.CourseOfferedID")
                                 .Join("Employee", "Employee.EmpID", "CourseFaculty.EmpID")
                                 .Where("SemesterName", semesterName)
                                 .Where("EmpName", empName).Get().Cast <IDictionary <string, object> >(); //get product by id=1
            }
            // STUDENT QUERIES
            else if (Action.Equals("GetStudentByName"))
            {
                object SName;
                dictJson.TryGetValue("SName", out SName);
                input_queryapi = SName.ToString();
                response       = db.Query("Student").WhereRaw("lower(SName) = ?", SName).Get().Cast <IDictionary <string, object> >();
            }
            else if (Action.Equals("GetStudentByStudentID"))
            {
                object RollNumber;
                dictJson.TryGetValue("RollNumber", out RollNumber);
                input_queryapi = RollNumber.ToString();
                response       = db.Query("Student").WhereRaw("lower(RollNumber) = ?", RollNumber).Get().Cast <IDictionary <string, object> >();
            }
            else if (Action.Equals("GetStudentByBatchID"))
            {
                object BatchID;
                dictJson.TryGetValue("BatchID", out BatchID);
                input_queryapi = BatchID.ToString();
                response       = db.Query("Student").WhereRaw("BatchID = ?", BatchID).Get().Cast <IDictionary <string, object> >();
            }
            else if (Action.Equals("GetStudentsByDepartment"))
            {
                object DepartmentName;
                dictJson.TryGetValue("DepartmentName", out DepartmentName);
                input_queryapi = DepartmentName.ToString();
                response       = db.Query("Student").Join("Programme", "Programme.ProgrammeID", "Student.ProgrammeID").Join("Department", "Department.DepartmentID", "Programme.DepartmentID")
                                 .Where("DepartmentName", DepartmentName).Get().Cast <IDictionary <string, object> >();
            }
            else if (Action.Equals("GetStudentsBySection"))
            {
                object SectionName;
                dictJson.TryGetValue("SectionName", out SectionName);
                input_queryapi = SectionName.ToString();
                response       = db.Query("Student").Join("Section", "Section.BatchID", "Student.BatchID")
                                 .Where("SectionName", SectionName).Get().Cast <IDictionary <string, object> >();
            }
            else if (Action.Equals("GetStudentByNUEmail"))
            {
                object Email;
                dictJson.TryGetValue("Email", out Email);
                input_queryapi = Email.ToString();
                response       = db.Query("Student").Join("CandidateStudent", "CandidateStudent.CandidateID", "Student.CandidateID")
                                 .Where("Student.Email", Email).Get().Cast <IDictionary <string, object> >();
            }
            else if (Action.Equals("GetStudentByPrimaryEmail"))
            {
                object Email;
                dictJson.TryGetValue("Email", out Email);
                input_queryapi = Email.ToString();
                response       = db.Query("Student").Join("CandidateStudent", "CandidateStudent.CandidateID", "Student.CandidateID")
                                 .Where("CandidateStudent.Email", Email).Get().Cast <IDictionary <string, object> >();
            }
            else if (Action.Equals("GetStudentsByNameStartsWith"))
            {
                object startNamePrefix;
                dictJson.TryGetValue("Sname", out startNamePrefix);
                input_queryapi = startNamePrefix.ToString();
                string prefixString = startNamePrefix.ToString() + "%";
                response = db.Query("Student").WhereLike("Sname", prefixString).Get().Cast <IDictionary <string, object> >();  //get product by id=1
            }
            else if (Action.Equals("GetStudentsByNameContains"))
            {
                object startNamePrefix;
                dictJson.TryGetValue("EmpName", out startNamePrefix);
                input_queryapi = startNamePrefix.ToString();
                string prefixString = "%" + startNamePrefix.ToString() + "%";
                response = db.Query("Student").WhereLike("Sname", prefixString).Get().Cast <IDictionary <string, object> >();  //get product by id=1
            }
            else if (Action.Equals("GetStudentsByCourseName"))
            {
                object CourseName;
                dictJson.TryGetValue("CourseName", out CourseName);
                input_queryapi = CourseName.ToString();
                response       = db.Query("Student").Join("CourseEnrollment", "CourseEnrollment.StudentID", "Student.StudentID").Join("Course", "Course.CourseID", "CourseEnrollment.CourseID")
                                 .Where("CourseName", CourseName).Get().Cast <IDictionary <string, object> >();
            }
            else if (Action.Equals("GetStudentsByCourseCode"))
            {
                object CourseCode;
                dictJson.TryGetValue("CourseCode", out CourseCode);
                input_queryapi = CourseCode.ToString();

                response = db.Query("Student").Join("CourseEnrollment", "CourseEnrollment.StudentID", "Student.StudentID").Join("Course", "Course.CourseID", "CourseEnrollment.CourseID")
                           .Where("CourseCode", CourseCode).Get().Cast <IDictionary <string, object> >();
            }
            else if (Action.Equals("GetStudentsBySkill"))
            {
                response = db.Query("StudentSkills").Join("Skill", "Skill.SkillID", "StudentSkills.SkillID").Join("Student", "StudentSkills.StudentID", "Student.StudentID")
                           .Get().Cast <IDictionary <string, object> >();
            }
            else if (Action.Equals("GetStudentsByDomain"))
            {
                response = db.Query("Domain").Join("Skill", "Skill.DomainID", "Domain.DomainID").Join("StudentSkills", "StudentSkills.SkillID", "Skill.SkillID").Join("Student", "Student.StudentID", "StudentSkills.StudentID")
                           .Get().Cast <IDictionary <string, object> >();
            }



            //var db1 = DbUtils.GetDBConnection();
            //db1.Connection.Open();

            SqlConnection dbConnection = new SqlConnection(ConfigurationManager.AppSettings["SqlDBConn"].ToString());



            try
            {
                /**
                 * db1.Query("dbo.SearchLog").AsInsert(new
                 * {
                 *  input_query = input_queryapi,
                 *  actionName = Action,
                 *  queried_by_username = userName.ToString()
                 * });
                 **/

                string query = "INSERT INTO dbo.SearchLog(input_query, actionName, queried_by_username) VALUES(@input_query,@actionName,@queried_by_username)";
                using (SqlCommand command = new SqlCommand(query, dbConnection))
                {
                    command.Parameters.AddWithValue("@input_query", input_queryapi);
                    command.Parameters.AddWithValue("@actionName", Action);
                    command.Parameters.AddWithValue("@queried_by_username", userName.ToString());

                    dbConnection.Open();
                    int result = command.ExecuteNonQuery();

                    // Check Error
                    if (result < 0)
                    {
                        Console.WriteLine("Error inserting data into Database!");
                    }
                }
            }
            catch (Exception e)
            {
            }



            return(Request.CreateResponse(HttpStatusCode.OK, response));
        }