示例#1
0
        private void btSaveUser_Click(object sender, EventArgs e)
        {
            if (!xValidateInputUser())
            {
                return;
            }

            using (var objDb = new clsDBUltity())
            {
                if (_mode == emModeForm.CreateNewUser)
                {
                    if (!objDb.InsertUser(txtUserName.Text, txtPassword.Text, txtFullName.Text, txtEmail.Text, cboRole.SelectedIndex))
                    {
                        Common.ShowMsg(MessageBoxIcon.Error, MSG_INSERT_ERR);
                        return;
                    }
                }
                else
                {
                    if (!objDb.UpdateUser(_userid, txtUserName.Text, txtPassword.Text, txtFullName.Text, txtEmail.Text, cboRole.SelectedIndex))
                    {
                        Common.ShowMsg(MessageBoxIcon.Error, MSG_UPDATE_ERR);
                        return;
                    }
                }

                xModeUser(emModeForm.CreateNewUser);
                grvUser.DataSource = objDb.GetMUser();
                grvUser.ClearSelection();
            }
        }
示例#2
0
        private void tabMngt_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (tabMngt.SelectedTab == tabUsers)
            {
                using (var objDb = new clsDBUltity())
                {
                    grvUser.DataSource = objDb.GetMUser();
                    grvUser.ClearSelection();
                }

                if (cboRole.Items.Count == 0)
                {
                    cboRole.Items.Add(ADMIN);
                    cboRole.Items.Add(USER);
                    cboRole.SelectedIndex = 0;
                }
            }
            else if (tabMngt.SelectedTab == tabChangePassword)
            {
                xResetModeChangePassword();
            }
        }
示例#3
0
        private void grvUser_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.RowIndex == -1)
            {
                return;
            }

            xModeUser(emModeForm.UpdateUser);

            _userid               = Common.CnvNullToInt(grvUser.Rows[e.RowIndex].Cells[colUserId.Index].Value);
            txtUserName.Text      = Common.CnvNullToString(grvUser.Rows[e.RowIndex].Cells[colUserName.Index].Value);
            txtPassword.Text      = Common.CnvNullToString(grvUser.Rows[e.RowIndex].Cells[colUserName.Index].Value);
            txtFullName.Text      = Common.CnvNullToString(grvUser.Rows[e.RowIndex].Cells[colFullName.Index].Value);
            txtEmail.Text         = Common.CnvNullToString(grvUser.Rows[e.RowIndex].Cells[colEmail.Index].Value);
            cboRole.SelectedIndex = Common.CnvNullToInt(grvUser.Rows[e.RowIndex].Cells[colRole.Index].Value);
            cboRole.Enabled       = _userid != Common.UserLoginId;

            if (e.ColumnIndex == colDeleteUser.Index)
            {
                if (_userid == Common.UserLoginId)
                {
                    return;
                }

                if (Common.ComfirmMsg(MSG_COMFIRM_DELETE))
                {
                    using (var objDb = new clsDBUltity())
                    {
                        objDb.DeleteUserById(_userid);
                        xModeUser(emModeForm.CreateNewUser);
                        grvUser.DataSource = objDb.GetMUser();
                        grvUser.ClearSelection();
                    }
                }
            }
        }
示例#4
0
        private void IntForm()
        {
            PathBase = Application.StartupPath;

            dgvMeasure.AutoGenerateColumns = false;

            using (var objDb = new clsDBUltity())
            {
                // Binding combobox User
                var tblUser = objDb.GetMUser();
                if (tblUser != null)
                {
                    var rowFirst = tblUser.NewRow();
                    rowFirst["username"] = "******";
                    rowFirst["userid"]   = -1;
                    tblUser.Rows.InsertAt(rowFirst, 0);
                    Common.BindingDataTableToComboBox(cmbUser, tblUser, "username", "userid", -1);
                }

                // Binding Type
                cmbType.DisplayMember = "Display";
                cmbType.ValueMember   = "Value";
                cmbType.Items.Add(new { Display = "All type", Value = -1 });
                cmbType.Items.Add(new { Display = "Alarm Test", Value = (int)clsDBUltity.emMeasureType.AlarmTest });
                cmbType.Items.Add(new { Display = "Walking Test", Value = (int)clsDBUltity.emMeasureType.WalkingTest });
                cmbType.SelectedIndex = 0;

                // Binding Status
                cmbStatus.DisplayMember = "Display";
                cmbStatus.ValueMember   = "Value";
                cmbStatus.Items.Add(new { Display = "Complete", Value = (int)clsDBUltity.emMeasureStatus.Complete });
                cmbStatus.Items.Add(new { Display = "Error", Value = (int)clsDBUltity.emMeasureStatus.Error });
                cmbStatus.SelectedIndex = 0;

                var dtStart = new DateTime(dtpStart.Value.Year, dtpStart.Value.Month, dtpStart.Value.Day, 0, 0, 0);
                var dtEnd   = new DateTime(dtpEnd.Value.Year, dtpEnd.Value.Month, dtpEnd.Value.Day, 23, 59, 59);

                var strSDate  = dtStart.ToString(clsDBUltity.cstrDateTimeFormatNoMiliSecond);
                var strEDate  = dtEnd.ToString(clsDBUltity.cstrDateTimeFormatNoMiliSecond);
                int intUser   = Common.CnvNullToInt(cmbUser.SelectedValue);
                int intType   = Common.CnvNullToInt(((dynamic)cmbType.SelectedItem).Value);
                int intResult = Common.CnvNullToInt(((dynamic)cmbResult.SelectedItem).Value);
                int intStatus = Common.CnvNullToInt(((dynamic)cmbStatus.SelectedItem).Value);

                // Binding grid measure
                dgvMeasure.DataSource = objDb.GetTBLMeasure(strSDate, strEDate, intUser, intType, intResult, intStatus);
                dgvMeasure.ClearSelection();
                if (dgvMeasure.Rows.Count > 0)
                {
                    dgvMeasure_CellClick(dgvMeasure, new DataGridViewCellEventArgs(0, 0));
                }

                dgvMeasure.Columns["colEnable"].Visible = false;

                if (Common.ModeApp == Common.emModeApp.User)
                {
                    lblStatus.Visible = false;
                    cmbStatus.Visible = false;
                    dgvMeasure.Columns["colDelete"].Visible = false;
                }
            }
        }