// ***************************************************************************************** // Kriterlere Göre Şirketin Data Hareketini Getir // ***************************************************************************************** protected void btnQuery_Click(object sender, EventArgs e) { try { spnNewUserRights.Visible = false; btnNewUserRights.Visible = false; this.FaultMessage.Visible = false; /// ---------------------------------------------------------------------------------------------------------- if (this.cboUsers.SelectedItem.Value != null) { DashboardUserRights objRights = new DashboardUserRights(); List<DashboardUserRights> dtRights = objRights.GetAllListForUserId(GlobalSettings.OrganizationConnectionString, Convert.ToInt32(this.cboUsers.SelectedItem.Value)); if (dtRights.Count == 0) { spnNewUserRights.Visible = true; btnNewUserRights.Visible = true; this.rptUserRights.Visible = false; } else { this.rptUserRights.Visible = true; this.rptUserRights.DataSource = dtRights; this.rptUserRights.DataBind(); foreach (RepeaterItem dataItem in rptUserRights.Items) { DashboardUserRights objAuthority = new DashboardUserRights(); bool Authority = objAuthority.GetItUpdateAuthorityForUserId(GlobalSettings.OrganizationConnectionString, HttpContext.Current.Session["userID"].ToString()); if (!Authority) { ((LinkButton)dataItem.FindControl("btnUpdate")).Enabled = false; ((LinkButton)dataItem.FindControl("btnUpdate")).ForeColor = Color.Gainsboro; } } } } else { Response.Write(@"<script language='javascript'>alert('Gerekli Alanları Seçmediniz!');</script>"); } } catch (Exception ex) { this.FaultMessage.Visible = true; this.lblException.Text = ex.Message.ToString(); } /// --------------------------------------------------------------------------------------------------------------- }
// ***************************************************************************************** // Yeni Kullanıcının Yetkilerini Kaydeder // ***************************************************************************************** protected void btnNewUserRights_Click(object sender, EventArgs e) { try { DashboardUserRights objUserRights = new DashboardUserRights(); objUserRights.UserId = Convert.ToInt32(this.cboUsers.SelectedItem.Value); objUserRights.InsertAuthority = this.chkInsert.Checked; objUserRights.UpdateAuthority = this.chkUpdate.Checked; objUserRights.DeleteAuthority = this.chkDelete.Checked; objUserRights.StartStopAuthority = this.chkStartStop.Checked; objUserRights.Insert(null, GlobalSettings.OrganizationConnectionString); this.SuccessMessage.Visible = true; btnQuery_Click(btnQuery, null); } catch (Exception ex) { this.FaultMessage.Visible = true; this.lblException.Text = ex.Message.ToString(); } }
// ***************************************************************************************** // Seçilen kayıtlar üzerinde güncelleme yapılır // ***************************************************************************************** protected void rptUserRights_ItemCommand(object source, RepeaterCommandEventArgs e) { try { if (e.CommandArgument.Equals("update")) { this.FaultMessage.Visible = false; string ChangingUserName = ((Label)e.Item.FindControl("lblUserName")).Text; // Yetkileri Güncelle DashboardUserRights objUserRights = new DashboardUserRights(); objUserRights.AuthorityId = Convert.ToInt32(((LinkButton)e.Item.FindControl("btnUpdate")).CommandName); objUserRights.UserId = Convert.ToInt32(this.cboUsers.SelectedItem.Value); objUserRights.InsertAuthority = ((CheckBox)e.Item.FindControl("chkInsert")).Checked; objUserRights.UpdateAuthority = ((CheckBox)e.Item.FindControl("chkUpdate")).Checked; objUserRights.DeleteAuthority = ((CheckBox)e.Item.FindControl("chkDelete")).Checked; objUserRights.StartStopAuthority = ((CheckBox)e.Item.FindControl("chkStartStop")).Checked; objUserRights.Update(null, GlobalSettings.OrganizationConnectionString); // İşlemi Logla DashboardLogSave(ChangingUserName); this.SuccessMessage.Visible = true; btnQuery_Click(btnQuery, null); } } catch (Exception ex) { this.FaultMessage.Visible = true; this.lblException.Text = ex.Message.ToString(); } }
// ***************************************************************************************** // Yetki Kontrolü // ***************************************************************************************** private void checkInsertAuthority() { DashboardUserRights objAuthority = new DashboardUserRights(); bool Authority = objAuthority.GetItInsertAuthorityForUserId(GlobalSettings.OrganizationConnectionString, HttpContext.Current.Session["userID"].ToString()); if (Authority) { this.btnNewUserRights.Enabled = true; this.spnNewUserRights.Disabled = false; } else { this.btnNewUserRights.Enabled = false; this.spnNewUserRights.Disabled = true; } }
public List<DashboardUserRights> GetAllListForUserId(string connectionString, int pUserId) { using (System.Data.SqlClient.SqlConnection connection = new System.Data.SqlClient.SqlConnection(connectionString)) { List<DashboardUserRights> DashboardUserRightsList = new List<DashboardUserRights>(); using (System.Data.SqlClient.SqlCommand cmd = new System.Data.SqlClient.SqlCommand()) { cmd.CommandText = @" SELECT DU.AuthorityId, DU.UserId, DUR.UserName, DU.InsertAuthority, DU.UpdateAuthority, DU.DeleteAuthority, DU.StartStopAuthority FROM DashboardUserRights AS DU, DashboardUser AS DUR WHERE DU.UserId = DUR.UserId AND DU.UserId = @pUserId"; cmd.Parameters.AddWithValue("@pUserId", pUserId); using (DataTable dt = DB_Gateway.ExecuteDataTable(cmd, connection)) { if (dt != null) { foreach (DataRow dr in dt.Rows) { DashboardUserRights objDashboardUserRights = new DashboardUserRights(); objDashboardUserRights.TransferToClass(dr); DashboardUserRightsList.Add(objDashboardUserRights); } } } } if (connection != null) connection.Close(); return DashboardUserRightsList; } }