コード例 #1
0
        private void DeleteRecordToolStripButton_Click(object sender, EventArgs e)
        {
            int rowIndex = StudentDataGridView.Rows.GetFirstRow(DataGridViewElementStates.Selected);

            SqlDataReader dataReader;

            try
            {
                if (rowIndex != -1)
                {
                    int StudentId = Convert.ToInt32(StudentDataGridView.Rows[rowIndex].Cells["StudentId"].Value);

                    string        query  = "DELETE FROM dbo.Student WHERE StudentId='" + StudentId + "';";
                    SqlConnection Sqlcon = new SqlConnection(AppSetting.ConnectionString());
                    SqlCommand    SqlCom = new SqlCommand(query, Sqlcon);
                    Sqlcon.Open();
                    dataReader = SqlCom.ExecuteReader();
                    SMSMessageBox.ShowSuccessMessage("Row Deleted");
                    while (dataReader.Read())
                    {
                    }
                    LoadDataIntoGridView();
                }
                else
                {
                    SMSMessageBox.ShowErrorMessage("Please Select Row");
                }
            }
            catch (Exception ex)
            {
                SMSMessageBox.ShowErrorMessage("Error Message");
            }
        }
コード例 #2
0
        public static List <SelectListItem> GetAllRoles(int roleId)
        {
            List <SelectListItem> roles = new List <SelectListItem>();

            using (SqlConnection conn = new SqlConnection(AppSetting.ConnectionString()))
            {
                using (SqlCommand cmd = new SqlCommand("usp_RolesGetRolesByRoleId", conn))
                {
                    cmd.CommandType = System.Data.CommandType.StoredProcedure;
                    conn.Open();

                    cmd.Parameters.AddWithValue("@RoleId", roleId);

                    SqlDataReader reader = cmd.ExecuteReader();

                    while (reader.Read())
                    {
                        SelectListItem item = new SelectListItem();
                        item.Value = reader["RoleName"].ToString();
                        item.Text  = reader["RoleName"].ToString();

                        roles.Add(item);
                    }
                }
            }

            return(roles);
        }
コード例 #3
0
        private void LoadDataAndBindIntoControls()
        {
            DbSQLServer dbSQLServer = new DbSQLServer(AppSetting.ConnectionString());
            DataTable   dataTabe    = dbSQLServer.GetDataList("usp_EmployeesGetEmployeesDetailsById", new DbParameter
            {
                Parameter = "@EmployeeId",
                Value     = this.EmployeeId
            });

            DataRow dtRow = dataTabe.Rows[0];

            EmployeeIDTextBox.Text           = dtRow["EmployeeId"].ToString();
            FullNameTextBox.Text             = dtRow["FullName"].ToString();
            dateTimePicker1.Value            = Convert.ToDateTime(dtRow["DateOfBirth"]);
            NICTextBox.Text                  = dtRow["NICNumber"].ToString();
            EmailTextBox.Text                = dtRow["EmailAddress"].ToString();
            TelephoneTextBox.Text            = dtRow["Telephone"].ToString();
            MobileETextBox.Text              = dtRow["Mobile"].ToString();
            dateTimePicker2.Value            = Convert.ToDateTime(dtRow["EmploymentDate"]);
            AddressLineTextBox.Text          = dtRow["AddressLine"].ToString();
            PostCodeBox.Text                 = dtRow["PostCode"].ToString();
            CurrentSalaryTextBox.Text        = dtRow["CurrentSalary"].ToString();
            StartingSalaryTextBox.Text       = dtRow["StartingSalary"].ToString();
            CommentsTextBox.Text             = dtRow["Comments"].ToString();
            pictureBox1.Image                = (dtRow["Photo"] is DBNull) ? null : ImageManipulations.PutPhoto((byte[])dtRow["Photo"]);
            CityComboBox.SelectedValue       = dtRow["CityId"];
            DistrictComboBox.SelectedValue   = dtRow["DistrictId"];
            GenderComboBox.SelectedValue     = dtRow["GenderId"];
            BranchComboBox.SelectedValue     = dtRow["BranchId"];
            JobTitleComboBox.SelectedValue   = dtRow["JobTitleId"];
            HasLeftComboBox.Text             = (Convert.ToBoolean(dtRow["HasLeft"]) == true) ? "Yes" : "No";
            ReasonLeftComboBox.SelectedValue = dtRow["ReasonLeftId"];
            DateLeftDateTimePicker.Value     = Convert.ToDateTime(dtRow["DateLeft"]);
            CommentsTextBox.Text             = dtRow["Comments"].ToString();
        }
コード例 #4
0
        public static List <UserModel> GetAllUsers()
        {
            List <UserModel> users = new List <UserModel>();

            using (SqlConnection conn = new SqlConnection(AppSetting.ConnectionString()))
            {
                using (SqlCommand cmd = new SqlCommand("usp_UsersGetAllUsers", conn))
                {
                    cmd.CommandType = System.Data.CommandType.StoredProcedure;
                    conn.Open();

                    SqlDataReader reader = cmd.ExecuteReader();

                    while (reader.Read())
                    {
                        UserModel user = new UserModel();
                        user.UserId   = Convert.ToInt32(reader["UserId"]);
                        user.UserName = reader["UserName"].ToString();
                        user.FullName = reader["FullName"].ToString();
                        user.Email    = reader["Email"].ToString();

                        users.Add(user);
                    }
                }
            }

            return(users);
        }
コード例 #5
0
        public static UserProfile GetUserProfileData(int currentUserId)
        {
            UserProfile userProfile = new UserProfile();

            using (SqlConnection conn = new SqlConnection(AppSetting.ConnectionString()))
            {
                using (SqlCommand cmd = new SqlCommand("usp_UsersGetUserProfileData", conn))
                {
                    cmd.CommandType = System.Data.CommandType.StoredProcedure;
                    conn.Open();

                    cmd.Parameters.AddWithValue("@UserId", currentUserId);

                    SqlDataReader reader = cmd.ExecuteReader();

                    reader.Read();

                    userProfile.FullName = reader["FullName"].ToString();
                    userProfile.Email    = reader["Email"].ToString();
                    userProfile.Address  = reader["Address"].ToString();
                }
            }

            return(userProfile);
        }
コード例 #6
0
        public static void LoadDataIntoDataGridView(DataGridView dgv, string storedProceName)
        {
            DBSQLServer db = new DBSQLServer(AppSetting.ConnectionString());

            dgv.DataSource          = db.GetDataList(storedProceName);
            dgv.MultiSelect         = false;
            dgv.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
            dgv.SelectionMode       = DataGridViewSelectionMode.FullRowSelect;
        }
コード例 #7
0
        public static void LoadDataIntoComboBox(ComboBox cb, string storedProceName, DBParameter[] parameters)
        {
            DBSQLServer db = new DBSQLServer(AppSetting.ConnectionString());

            cb.DataSource    = db.GetDataList(storedProceName, parameters);
            cb.DisplayMember = "Description";
            cb.ValueMember   = "Id";
            cb.SelectedIndex = -1;
            cb.DropDownStyle = ComboBoxStyle.DropDownList;
        }
コード例 #8
0
        public static void LoadDataIntoComboBox(ComboBox cb, DBParameter parameter)
        {
            DBSQLServer db = new DBSQLServer(AppSetting.ConnectionString());

            cb.DataSource    = db.GetDataList("usp_ListTypesDataGetDataByListTypeId", parameter);
            cb.DisplayMember = "Description";
            cb.ValueMember   = "Id";
            cb.SelectedIndex = -1;
            cb.DropDownStyle = ComboBoxStyle.DropDownList;
        }
コード例 #9
0
        public static void LoadDataIntoComboBox(ComboBox comboBox, string storedProcedureName, DbParameter[] dbParameters)
        {
            DbSQLServer dbSQLServer = new DbSQLServer(AppSetting.ConnectionString());

            comboBox.DataSource = dbSQLServer.GetDataList(storedProcedureName, dbParameters);

            comboBox.DisplayMember = "Description";
            comboBox.ValueMember   = "Id";
            comboBox.SelectedIndex = -1;
            comboBox.DropDownStyle = ComboBoxStyle.DropDownList;
        }
コード例 #10
0
        public static void LoadDataIntoComboBox(ComboBox comboBox, DbParameter dbParameter)
        {
            DbSQLServer dbSQLServer = new DbSQLServer(AppSetting.ConnectionString());

            comboBox.DataSource = dbSQLServer.GetDataList("usp_GetListTypesDataById", dbParameter);

            comboBox.DisplayMember = "Description";
            comboBox.ValueMember   = "Id";
            comboBox.SelectedIndex = -1;
            comboBox.DropDownStyle = ComboBoxStyle.DropDownList;
        }
コード例 #11
0
        private void SearchTextBox_TextChanged(object sender, EventArgs e)
        {
            Sqlcon = new SqlConnection(AppSetting.ConnectionString());
            string query = "SELECT * FROM dbo.Student WHERE StudentName LIKE'" + SearchTextBox.Text + "%'";

            Sqlcon.Open();
            SqlCommand SqlCom = new SqlCommand(query, Sqlcon);

            SqlDataAdapter adp = new SqlDataAdapter(SqlCom);
            DataTable      dt  = new DataTable();

            adp.Fill(dt);
            StudentDataGridView.DataSource = dt;
        }
コード例 #12
0
        public static void UpdateUserProfile(UserProfile userProfile)
        {
            using (SqlConnection conn = new SqlConnection(AppSetting.ConnectionString()))
            {
                using (SqlCommand cmd = new SqlCommand("usp_UsersUpdateUserProfile", conn))
                {
                    cmd.CommandType = System.Data.CommandType.StoredProcedure;
                    conn.Open();

                    cmd.Parameters.AddWithValue("@UserId", WebSecurity.CurrentUserId);
                    cmd.Parameters.AddWithValue("@FullName", userProfile.FullName);
                    cmd.Parameters.AddWithValue("@Email", userProfile.Email);
                    cmd.Parameters.AddWithValue("@Address", userProfile.Address);

                    cmd.ExecuteNonQuery();
                }
            }
        }
コード例 #13
0
 private void SignInButton_Click(object sender, EventArgs e)
 {
     if (isFormValid())
     {
         DBSQLServer db = new DBSQLServer(AppSetting.ConnectionString());
         bool        isLoginDetailsCorrect = Convert.ToBoolean(db.GetScalarValue("usp_UsersCheckLoginDetails", GetParameter()));
         if (isLoginDetailsCorrect)
         {
             GetLoggedInUserSetting();
             this.Hide();
             DashboardForm df = new DashboardForm();
             df.Show();
         }
         else
         {
             SMSMessageBox.ShowErrorMessage("User name/Password is not correct");
         }
     }
 }
コード例 #14
0
        private void LoadDataAndBindIntoControls()
        {
            DBSQLServer db         = new DBSQLServer(AppSetting.ConnectionString());
            DataTable   dtEmployee = db.GetDataList("usp_EmployeesGetEmployeeDetailsId", new DBParameter
            {
                Parameter = "@EmployeeId",
                Value     = this.EmployeeId
            });

            DataRow row = dtEmployee.Rows[0];

            EmployeeIdTextBox.Text          = row["EmployeeId"].ToString();
            FullNameTextBox.Text            = row["FullName"].ToString();
            DateOfBirthDateTimePicker.Value = Convert.ToDateTime(row["DateOfBirth"]);
            CNICTextBox.Text                   = row["CNICNumber"].ToString();
            EmailAddressTextBox.Text           = row["EmailAddress"].ToString();
            MobileTextBox.Text                 = row["Mobile"].ToString();
            TelephoneTextBox.Text              = row["Telephone"].ToString();
            GenderComboBox.SelectedValue       = row["GenderId"];
            EmploymentDateDateTimePicker.Value = Convert.ToDateTime(row["EmploymentDate"]);
            BranchComboBox.SelectedValue       = row["BranchId"];
            PhotoPictureBox.Image              = (row["Photo"] is DBNull) ? null : ImageManipulation.PutPhoto((byte[])row["Photo"]);
            AddressLineTextBox.Text            = row["AddressLine"].ToString();
            CityComboBox.SelectedValue         = row["CityId"];
            DistrictComboBox.SelectedValue     = row["DistrictId"];
            PostralCodeTextBox.Text            = row["PostralCode"].ToString();
            JobTitleComboBox.SelectedValue     = row["JobTitleId"];
            CurrentSalaryTextBox.Text          = row["CurrentSalary"].ToString();
            StartingSalaryTextBox.Text         = row["StartingSalary"].ToString();
            HasLeftComboBox.Text               = (Convert.ToBoolean(row["HasLeft"]) == true) ? "Yes" : "No";
            if (row["DateLeft"] is DBNull)
            {
                DateLeftDateTimePicker.CustomFormat = " ";
            }
            else
            {
                DateLeftDateTimePicker.Value = Convert.ToDateTime(row["DateLeft"]);
            }

            ReasonLeftComboBox.SelectedValue = row["ReasonLeftId"];
            CommentsTextBox.Text             = row["Comments"].ToString();
        }
コード例 #15
0
        private void LoadDataAndBindIntoControls()
        {
            DBSQLServer db         = new DBSQLServer(AppSetting.ConnectionString());
            DataTable   dtEmployee = db.GetDataList("usp_StudentGetStudentDetailsById", new DBParameter
            {
                Parameter = "@StudentId",
                Value     = this.StudentId
            });

            DataRow row = dtEmployee.Rows[0];

            StudentIdTextBox.Text            = row["StudentId"].ToString();
            StudentNameTextBox.Text          = row["StudentName"].ToString();
            FatherNameTextBox.Text           = row["FatherName"].ToString();
            PhoneNumberTextBox.Text          = row["PhoneNumber"].ToString();
            CityComboBox.SelectedValue       = row["CityId"];
            EmailAddressTextBox.Text         = row["EmailAddress"].ToString();
            DepartmentComboBox.SelectedValue = row["DepartmentId"];
            AddressLineTextBox.Text          = row["AddressLine"].ToString();
        }
コード例 #16
0
        private void btnLogin_Click(object sender, EventArgs e)
        {
            if (IsFormValid())
            {
                DbSQLServer db = new DbSQLServer(AppSetting.ConnectionString());

                bool isLoginDetailsCorrect = Convert.ToBoolean(db.GetScalarValue("sp_CheckLoginDetails", GetPrameters()));

                if (isLoginDetailsCorrect)
                {
                    this.Hide();
                    frmDashboard frm = new frmDashboard();
                    frm.Show();
                }
                else
                {
                    MessageBox.Show("Netačno korisničko ime ili šifra.\nPokušajte opet.", "Greška", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
コード例 #17
0
        private void LoadDataAndBindToControlIfUpdate()
        {
            if (this.IsUpdate)
            {
                DBSQLServer db   = new DBSQLServer(AppSetting.ConnectionString());
                DBParameter para = new DBParameter();
                para.Parameter = "@BranchId";
                para.Value     = this.BranchId;
                DataTable dtBranch = db.GetDataList("usp_BranchesGetBranchDetailByBranchId", para);
                DataRow   row      = dtBranch.Rows[0];

                BranchNameTextBox.Text             = row["BranchName"].ToString();
                EmailAddressTextBox.Text           = row["Email"].ToString();
                TelephoneTextBox.Text              = row["Telephone"].ToString();
                WebSiteAddressTextBox.Text         = row["WebSite"].ToString();
                AddressLineTextBox.Text            = row["AddressLine"].ToString();
                CityNameComboBox.SelectedValue     = row["CityId"];
                DistrictNameComboBox.SelectedValue = row["DistrictId"];
                PostralCodeTextBox.Text            = row["PostralCode"].ToString();
                LogoPictureBox.Image = (row["branchImage"] is DBNull) ? null : ImageManipulation.PutPhoto((byte[])row["branchImage"]);
            }
        }
コード例 #18
0
        private void btnSignIn_Click(object sender, EventArgs e)
        {
            if (IsFormValid())
            {
                DbSQLServer dbSQLServer = new DbSQLServer(AppSetting.ConnectionString());

                bool isLoginDetailsCorrect = Convert.ToBoolean(dbSQLServer.GetScalarValue("usp_UsersCheckLoginDetails", GetParameters()));

                if (isLoginDetailsCorrect)
                {
                    GetLoggedInUserSettings();
                    this.Hide();

                    DashboardForm dashboardForm = new DashboardForm();
                    dashboardForm.Show();
                }

                else
                {
                    JIMessageBox.ShowErrorMessage("User Name/Password is incorrect");
                    //MessageBox.Show("User Name/Password is incorrect", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
コード例 #19
0
        private void LoadDataAndBindToControlIfUpdate()
        {
            if (this.IsUpdate)
            {
                DbSQLServer dbSQLServer = new DbSQLServer(AppSetting.ConnectionString());
                //DbParameter dbPara = new DbParameter();
                //dbPara.Parameter = "@BranchId";
                //dbPara.Value = this.BranchId;
                DataTable dtBranchTable = dbSQLServer.GetDataList("usp_BranchesGetBrancheDetailByBranchId", new DbParameter {
                    Parameter = "@BranchId", Value = this.BranchId
                });
                DataRow row = dtBranchTable.Rows[0];

                BranchNameTextBox.Text          = row["BranchName"].ToString();
                EmailTextBox.Text               = row["Email"].ToString();
                MobileTextBox.Text              = row["Mobile"].ToString();
                WebAddressTextBox.Text          = row["Website"].ToString();
                LogoPictureBox.Image            = (row["branchImage"] is DBNull)? null : ImageManipulations.PutPhoto((byte[])row["branchImage"]);
                AddressLineTextBox.Text         = row["AddressLine"].ToString();
                CityComboBox1.SelectedValue     = row["CityId"];
                DistrictComboBox2.SelectedValue = row["DistrictId"];
                PostCodeTextBox.Text            = row["PostCode"].ToString();
            }
        }
コード例 #20
0
        private void GenerateStudentId()
        {
            DBSQLServer db = new DBSQLServer(AppSetting.ConnectionString());

            StudentIdTextBox.Text = db.GetScalarValue("usp_StudentsGenerateNewStudentId").ToString();
        }
コード例 #21
0
        private void SaveOrUpdateRecord(string storedProceName)
        {
            DBSQLServer db = new DBSQLServer(AppSetting.ConnectionString());

            db.SaveOrUpdateRecord(storedProceName, GetObject());
        }
コード例 #22
0
        private void GenerateEmployeeId()
        {
            DbSQLServer dBSQLSerevr = new DbSQLServer(AppSetting.ConnectionString());

            EmployeeIDTextBox.Text = dBSQLSerevr.GetScalarValue("usp_EmployeesGenerateNewEmployeeId").ToString();
        }