public static BindingListView<Role> Get() { BindingListView<Role> view = new BindingListView<Role>(); foreach (Role role in GetRoles()) { view.Add(role); } foreach (Role role2 in GetRights()) { view.Add(role2); } return view; }
public virtual void AddElem(T element) { if (element != null) { elements.Add(element); } }
private void AddElement() { BindingListView <EntityElementTemplate> source = clstElement.DataSource as BindingListView <EntityElementTemplate>; if (source != null) { BindingListView <EntityElementTemplate> tempSource = new BindingListView <EntityElementTemplate>(); EntityElementTemplate objNew = new EntityElementTemplate(); objNew.serno = -1; objNew.colcontent = " "; tempSource.Add(objNew); foreach (EntityElementTemplate objCurrent in source) { tempSource.Add(objCurrent); } clstElement.DataSource = tempSource; } biAdd.Enabled = false; biDel.Enabled = false; biMultiChoose.Enabled = false; biEdit.Enabled = false; txtNew = new DevExpress.XtraEditors.TextEdit(); txtNew.Name = "txtNew"; int intCount = clstElement.ItemCount; int intHeight = (intCount + 1) * clstElement.ItemHeight; txtNew.Location = new Point(0, 0); if (clstElement.Height <= intHeight) { txtNew.Width = clstElement.Width - 17; } else { txtNew.Width = clstElement.Width; } txtNew.Height = clstElement.ItemHeight; txtNew.KeyDown += new KeyEventHandler(txtNew_KeyDown); txtNew.Leave += new EventHandler(txtNew_Leave); clstElement.Controls.Add(txtNew); txtNew.BringToFront(); txtNew.Focus(); }
public static DailyMileEntries MergeEntries(string fileName, DailyMileEntries entries) { BindingListView<DailyMileEntry> fileentries; BindingListView<DailyMileEntry> downloadedEntries; DailyMileEntries murgedEntries; murgedEntries = new DailyMileEntries(); try { //convert downloaded entries to BLV downloadedEntries = new BindingListView<DailyMileEntry>(entries.Entries); //Read stored collection fileentries = new BindingListView<DailyMileEntry>(DailyMileAPI.GetStoredEntries(fileName).Entries); foreach (DailyMileEntry entry in downloadedEntries) { if (fileentries != null) { if (fileentries.Exists("ID", entry.ID) == true) { fileentries.RemoveItems("ID", entry.ID); } } fileentries.Add(entry); } using (FileStream fs = new FileStream(fileName, FileMode.Create, FileAccess.Write, FileShare.None)) { using (BinaryWriter binWriter = new BinaryWriter(fs)) { murgedEntries = new DailyMileEntries(); fileentries.SortDirection = ListSortDirection.Descending; fileentries.SortFields = "ID"; murgedEntries.Entries = fileentries.GetList(); binWriter.Write(SerializersJSON.Serialize<DailyMileEntries>(murgedEntries)); } } } catch (VSException ve) { throw ve; } catch (System.Exception ex) { throw new VSException(string.Format("MergeEntries FileName({0}) Exception {1}", fileName, ex.Message)); } return murgedEntries; }
public BindingListView<PayPaymentOrderPackPayment> FindByPaymentOrderPackId(long paymentOrderPackId) { System.Data.SqlClient.SqlParameter[] parameters = new System.Data.SqlClient.SqlParameter[] { new System.Data.SqlClient.SqlParameter("@paymentOrderPackId", System.Data.SqlDbType.BigInt) }; parameters[0].set_Value((long) paymentOrderPackId); BindingListView<PayPaymentOrderPackPayment> view = new BindingListView<PayPaymentOrderPackPayment>(); foreach (System.Data.DataRow row in DALSql.ExecuteDataTable(this.SelectQuery + "where paymentOrderPackId=@paymentOrderPackId", parameters).Rows) { PayPaymentOrderPackPayment owid = new PayPaymentOrderPackPayment(); this.Load(row, owid); view.Add(owid); } return view; }
public BindingListView<FixedSummServiceView> Find(ServiceOld serviceOld, LocalAddress address) { BindingListView<FixedSummServiceView> view = new BindingListView<FixedSummServiceView>(); System.Data.SqlClient.SqlParameter[] parameters = new System.Data.SqlClient.SqlParameter[2]; parameters[0] = new System.Data.SqlClient.SqlParameter("@serviceId", System.Data.SqlDbType.BigInt); parameters[0].set_Value((long) serviceOld.Id); parameters[1] = new System.Data.SqlClient.SqlParameter("@addrId", System.Data.SqlDbType.BigInt); parameters[1].set_Value((long) address.Id); foreach (System.Data.DataRow row in DALSql.ExecuteDataTable(this.SelectFields + " from [sn].[GetFixedSummServices](@serviceId ,@addrId) t", parameters).Rows) { FixedSummServiceView view2 = this.Load(row); view.Add(view2); } return view; }
private void bbiGenerarFactura_Click(object sender, EventArgs e) { int serie = Int32.Parse(dgvAlbaranes.Rows[dgvAlbaranes.CurrentRow.Index].Cells[0].Value.ToString()); string codigo = dgvAlbaranes.Rows[dgvAlbaranes.CurrentRow.Index].Cells[1].Value.ToString(); Albaran albaran = Albaran.GetWhere(Conexiones.conexion, $"Serie = {serie} AND Codigo = '{codigo}'").FirstOrDefault(); if (albaran != null) { BindingListView <LineasAlbaran> lineasAlbarans = LineasAlbaran.GetWhere(Conexiones.conexion, $"Serie = {serie} AND Codigo = '{codigo}'"); if (lineasAlbarans != null) { DialogResult dialogResult = MessageBox.Show($"Se va a crear una factura de venta\n¿Está seguro?", "Generar Factura de venta", MessageBoxButtons.YesNo); if (dialogResult == DialogResult.Yes) { FacturaVenta facturaVenta = new FacturaVenta(); //pedidoVenta.Serie = presupuestoVenta.Serie; //pedidoVenta.Codigo = presupuestoVenta.Codigo; facturaVenta.Cliente = albaran.Cliente; facturaVenta.Total = albaran.Total; facturaVenta.Observaciones = albaran.Observaciones; facturaVenta.DocumentoEvolucion = $"{albaran.Serie}-{albaran.Codigo}"; //PedidoVenta.Save(Conexiones.conexion, pedidoVenta); BindingListView <LineasFacturaVenta> lineasFacturaVentas = new BindingListView <LineasFacturaVenta>(); foreach (LineasAlbaran lineaAlbaran in lineasAlbarans) { LineasFacturaVenta linea = new LineasFacturaVenta(); //linea.Serie = lineaPresupuesto.Serie; //linea.Codigo = lineaPresupuesto.Codigo; //linea.Posicion = lineaPresupuesto.Posicion; linea.CodArticulo = lineaAlbaran.CodArticulo; linea.Descripcion = lineaAlbaran.Descripcion; linea.Cantidad = lineaAlbaran.Cantidad; linea.PrecioCoste = lineaAlbaran.PrecioCoste; linea.PrecioVenta = lineaAlbaran.PrecioVenta; lineasFacturaVentas.Add(linea); } frmDocumento frmDocumento = new frmDocumento(facturaVenta, lineasFacturaVentas); frmDocumento.ShowDialog(); } } } }
private void bbiGenerarPedido_Click(object sender, EventArgs e) { int serie = Int32.Parse(dgvPresupuestosVenta.Rows[dgvPresupuestosVenta.CurrentRow.Index].Cells[0].Value.ToString()); string codigo = dgvPresupuestosVenta.Rows[dgvPresupuestosVenta.CurrentRow.Index].Cells[1].Value.ToString(); PresupuestoVenta presupuestoVenta = PresupuestoVenta.GetWhere(Conexiones.conexion, $"Serie = {serie} AND Codigo = '{codigo}'").FirstOrDefault(); if (presupuestoVenta != null) { BindingListView <LineasPresupuestoVenta> lineasPresupuestoVentas = LineasPresupuestoVenta.GetWhere(Conexiones.conexion, $"Serie = {serie} AND Codigo = '{codigo}'"); if (lineasPresupuestoVentas != null) { DialogResult dialogResult = MessageBox.Show($"Se va a crear un pedido\n¿Está seguro?", "Generar pedido", MessageBoxButtons.YesNo); if (dialogResult == DialogResult.Yes) { PedidoVenta pedidoVenta = new PedidoVenta(); //pedidoVenta.Serie = presupuestoVenta.Serie; //pedidoVenta.Codigo = presupuestoVenta.Codigo; pedidoVenta.Cliente = presupuestoVenta.Cliente; pedidoVenta.Total = presupuestoVenta.Total; pedidoVenta.Observaciones = presupuestoVenta.Observaciones; pedidoVenta.DocumentoEvolucion = $"{presupuestoVenta.Serie}-{presupuestoVenta.Codigo}"; //PedidoVenta.Save(Conexiones.conexion, pedidoVenta); BindingListView <LineasPedidoVenta> lineasPedidoVentas = new BindingListView <LineasPedidoVenta>(); foreach (LineasPresupuestoVenta lineaPresupuesto in lineasPresupuestoVentas) { LineasPedidoVenta linea = new LineasPedidoVenta(); //linea.Serie = lineaPresupuesto.Serie; //linea.Codigo = lineaPresupuesto.Codigo; //linea.Posicion = lineaPresupuesto.Posicion; linea.CodArticulo = lineaPresupuesto.CodArticulo; linea.Descripcion = lineaPresupuesto.Descripcion; linea.Cantidad = lineaPresupuesto.Cantidad; linea.PrecioCoste = lineaPresupuesto.PrecioCoste; linea.PrecioVenta = lineaPresupuesto.PrecioVenta; lineasPedidoVentas.Add(linea); } frmDocumento frmDocumento = new frmDocumento(pedidoVenta, lineasPedidoVentas); frmDocumento.ShowDialog(); } } } }
public BindingListView<OldRole> GetRoles(string typeRole) { System.Data.SqlClient.SqlParameter[] parameters = new System.Data.SqlClient.SqlParameter[] { new System.Data.SqlClient.SqlParameter("@typeRole", System.Data.SqlDbType.VarChar) }; parameters[0].set_Value(typeRole); BindingListView<OldRole> view = new BindingListView<OldRole>(); foreach (System.Data.DataRow row in DALSql.ExecuteDataTable(this.SelectQuery + " where typeRole = @typeRole", parameters).Rows) { OldRole owid = new OldRole(); this.Load(row, owid); view.Add(owid); } return view; }
public BindingListView<OldRole> FindIncludeRolesBy(User user) { System.Data.SqlClient.SqlParameter[] parameters = new System.Data.SqlClient.SqlParameter[] { new System.Data.SqlClient.SqlParameter("@name", System.Data.SqlDbType.VarChar) }; parameters[0].set_Value(user.Login); string sql = this.SelectQuery + " \r\n inner join sys.database_role_members rm on t.id = rm.role_principal_id \r\n\t\t inner join sys.database_principals pr on rm.member_principal_id = pr.principal_id\r\n where pr.type='S' /*and t.typeRole in ('РОЛЬ')*/ and pr.[name] = @name\r\n union\r\n " + this.SelectQueryAR + "\r\n inner join sn.UserRights ur on tar.id = ur.RightId\r\n inner join sn.Users u on ur.UserId = u.id and u.login = @name\r\n\t where tar.TypeId = 4"; BindingListView<OldRole> view = new BindingListView<OldRole>(); foreach (System.Data.DataRow row in DALSql.ExecuteDataTable(sql, parameters).Rows) { OldRole owid = new OldRole(); this.Load(row, owid); view.Add(owid); } return view; }
public BindingListView<OldRole> FindIncludeRolesBy(OldRole role) { System.Data.SqlClient.SqlParameter[] parameters = new System.Data.SqlClient.SqlParameter[] { new System.Data.SqlClient.SqlParameter("@id", System.Data.SqlDbType.BigInt) }; parameters[0].set_Value((long) role.Id); string sql = this.SelectQuery + " inner join sys.database_role_members rm on t.id = rm.role_principal_id \r\n where\trm.member_principal_id = @id"; BindingListView<OldRole> view = new BindingListView<OldRole>(); foreach (System.Data.DataRow row in DALSql.ExecuteDataTable(sql, parameters).Rows) { OldRole owid = new OldRole(); this.Load(row, owid); view.Add(owid); } return view; }
public BindingListView<OldRole> FindIncludeRoleRightsBy(User user, OldRole r) { System.Data.SqlClient.SqlParameter[] parameters = new System.Data.SqlClient.SqlParameter[2]; parameters[0] = new System.Data.SqlClient.SqlParameter("@name", System.Data.SqlDbType.VarChar); parameters[0].set_Value(user.Login); parameters[1] = new System.Data.SqlClient.SqlParameter("@role", System.Data.SqlDbType.VarChar); parameters[1].set_Value((long) r.Id); string sql = this.SelectQuery + " inner join sys.database_role_members rm on t.id = rm.role_principal_id\r\n inner join sn.RolesView rv on rv.id = rm.member_principal_id\r\n inner join sys.database_role_members rm2 on rv.id = rm2.role_principal_id /*and rv.typeRole in ('РОЛЬ')*/ and rv.id = @role\r\n inner join sys.database_principals pr on rm2.member_principal_id = pr.principal_id and pr.type = 'S' and pr.name = @name\r\n "; BindingListView<OldRole> view = new BindingListView<OldRole>(); foreach (System.Data.DataRow row in DALSql.ExecuteDataTable(sql, parameters).Rows) { OldRole owid = new OldRole(); this.Load(row, owid); view.Add(owid); } return view; }
public BindingListView<OldRole> FindExcludeRolesBy(OldRole role) { System.Data.SqlClient.SqlParameter[] parameters = new System.Data.SqlClient.SqlParameter[] { new System.Data.SqlClient.SqlParameter("@id", System.Data.SqlDbType.BigInt) }; parameters[0].set_Value((long) role.Id); string sql = this.SelectQuery + " where\t/*t.typeRole in ('РОЛЬ','ПРАВО')\r\n\t\t and*/ t.id <> @id\r\n and not t.id in\t(select role_principal_id\r\n\t\t\t\t\t from\tsys.database_role_members \r\n\t\t\t\t\t where\tmember_principal_id = @id)"; BindingListView<OldRole> view = new BindingListView<OldRole>(); foreach (System.Data.DataRow row in DALSql.ExecuteDataTable(sql, parameters).Rows) { OldRole owid = new OldRole(); this.Load(row, owid); view.Add(owid); } return view; }
public BindingListView<OldRole> FindExcludeRightsCurrentUser() { System.Data.SqlClient.SqlParameter[] parameters = new System.Data.SqlClient.SqlParameter[0]; string sql = this.SelectField + " from sn.GetExcludeUserRoles t "; BindingListView<OldRole> view = new BindingListView<OldRole>(); foreach (System.Data.DataRow row in DALSql.ExecuteDataTable(sql, parameters).Rows) { OldRole owid = new OldRole(); this.Load(row, owid); view.Add(owid); } return view; }
public BindingListView<OldRole> FindExcludeRightsBy(User user) { System.Data.SqlClient.SqlParameter[] parameters = new System.Data.SqlClient.SqlParameter[] { new System.Data.SqlClient.SqlParameter("@name", System.Data.SqlDbType.VarChar) }; parameters[0].set_Value(user.Login); string sql = this.SelectQuery + " where\t/*t.typeRole in ('РОЛЬ','ПРАВО') \r\n and*/ not t.id in (\tselect\tt.id\r\n\t from\tsn.RolesView t\r\n inner join sys.database_role_members rm on t.id = rm.role_principal_id\r\n\t\t inner join sys.database_principals pr on rm.member_principal_id = pr.principal_id\r\n inner join sys.database_role_members rm2 on pr.principal_id = rm2.role_principal_id\r\n\t\t inner join sys.database_principals pr2 on rm2.member_principal_id = pr2.principal_id\r\n inner join sys.database_role_members rm3 on pr2.principal_id = rm3.role_principal_id\r\n\t\t inner join sys.database_principals pr3 on rm3.member_principal_id = pr3.principal_id\r\n inner join sys.database_role_members rm4 on pr3.principal_id = rm4.role_principal_id\r\n\t \t inner join sys.database_principals pr4 on rm4.member_principal_id = pr4.principal_id\r\n where pr4.type='S' \r\n /*and t.typeRole in ('РОЛЬ','ПРАВО') */\r\n and pr4.[name] = @name \r\n union\r\n select\tt.id\r\n\t from\tsn.RolesView t\r\n inner join sys.database_role_members rm on t.id = rm.role_principal_id\r\n\t\t inner join sys.database_principals pr on rm.member_principal_id = pr.principal_id\r\n inner join sys.database_role_members rm2 on pr.principal_id = rm2.role_principal_id\r\n\t\t inner join sys.database_principals pr2 on rm2.member_principal_id = pr2.principal_id\r\n inner join sys.database_role_members rm3 on pr2.principal_id = rm3.role_principal_id\r\n\t\t inner join sys.database_principals pr3 on rm3.member_principal_id = pr3.principal_id\r\n where pr3.type='S' \r\n /*and t.typeRole in ('РОЛЬ','ПРАВО') */\r\n and pr3.[name] = @name\r\n union \r\n select\tt.id\r\n\t from\tsn.RolesView t\r\n inner join sys.database_role_members rm on t.id = rm.role_principal_id\r\n\t\t inner join sys.database_principals pr on rm.member_principal_id = pr.principal_id\r\n inner join sys.database_role_members rm2 on pr.principal_id = rm2.role_principal_id\r\n\t\t inner join sys.database_principals pr2 on rm2.member_principal_id = pr2.principal_id\r\n where pr2.type='S' \r\n /*and t.typeRole in ('РОЛЬ','ПРАВО') */\r\n and pr2.[name] = @name\r\n union\r\n select\tt.id\r\n\t from\tsn.RolesView t\r\n inner join sys.database_role_members rm on t.id = rm.role_principal_id\r\n\t\t inner join sys.database_principals pr on rm.member_principal_id = pr.principal_id\r\n where pr.type='S' \r\n /*and t.typeRole in ('РОЛЬ','ПРАВО') */\r\n and pr.[name] = @name) "; BindingListView<OldRole> view = new BindingListView<OldRole>(); foreach (System.Data.DataRow row in DALSql.ExecuteDataTable(sql, parameters).Rows) { OldRole owid = new OldRole(); this.Load(row, owid); view.Add(owid); } return view; }
public BindingListView<Role> FindExcludeRightsBy(User user) { System.Data.SqlClient.SqlParameter[] parameters = new System.Data.SqlClient.SqlParameter[] { new System.Data.SqlClient.SqlParameter("@userId", System.Data.SqlDbType.BigInt) }; parameters[0].set_Value((long) user.Id); string sql = "select r.id, r.name, r.TypeId\r\n\tinto #t\r\n\tfrom sn.Rights r\r\n\t\tinner join sn.UserRights ur on ur.RightId = r.id\r\n\t\tinner join sn.Users u on ur.UserId = u.id\r\n\twhere u.id = @userId\r\n\tunion \r\n\tselect rr.id, rr.name, rr.TypeId\r\n\t\tfrom sn.UserRights ur\r\n\t\tinner join sn.Users u on ur.UserId = u.id\r\n\t\tinner join sn.Rights r on ur.RightId = r.id\r\n\t\tinner join sn.RightGroups rg on r.id = rg.GroupId\r\n\t\tinner join sn.Rights rr on rg.RightId = rr.id\r\n\twhere r.TypeId = 2 and u.id = @userId\r\n\tunion \r\n\tselect rrr.id, rrr.name, rrr.TypeId\r\n\tfrom sn.UserRights ur\r\n\t\tinner join sn.Users u on ur.UserId = u.id\r\n\t\tinner join sn.Rights r on ur.RightId = r.id\r\n\t\tinner join sn.RightGroups rg on r.id = rg.GroupId\r\n\t\tinner join sn.Rights rr on rg.RightId = rr.id\r\n\t\tinner join sn.RightGroups rrg on rr.id = rrg.GroupId\r\n\t\tinner join sn.Rights rrr on rrg.RightId = rrr.id\r\n\twhere r.TypeId = 2 and rr.TypeId = 2 and u.id = @userId\r\n" + this.SelectQuery + "\r\n\twhere t.id not in (select tt.id from #t tt) and t.TypeId not in (select id from sn.RightTypes where [name] like 'Роль%')"; BindingListView<Role> view = new BindingListView<Role>(); foreach (System.Data.DataRow row in DALSql.ExecuteDataTable(sql, parameters).Rows) { Role owid = new Role(); this.Load(row, owid); view.Add(owid); } return view; }
public BindingListView<Role> FindExcludeRolesBy(Role role) { System.Data.SqlClient.SqlParameter[] parameters = new System.Data.SqlClient.SqlParameter[] { new System.Data.SqlClient.SqlParameter("@id", System.Data.SqlDbType.BigInt) }; parameters[0].set_Value((int) role.Id); string sql = this.SelectQuery + " where t.id <> @id\r\n and t.TypeId in (1, 2)\r\n and t.id not in\t(select rg.RightId\r\n\t\t\t\t\t from sn.RightGroups rg\r\n where rg.GroupId = @id)"; BindingListView<Role> view = new BindingListView<Role>(); foreach (System.Data.DataRow row in DALSql.ExecuteDataTable(sql, parameters).Rows) { Role owid = new Role(); this.Load(row, owid); view.Add(owid); } return view; }
public BindingListView<Role> GetRoles(RightTypesEnum rType) { System.Data.SqlClient.SqlParameter[] parameters = new System.Data.SqlClient.SqlParameter[] { new System.Data.SqlClient.SqlParameter("@type", System.Data.SqlDbType.BigInt) }; parameters[0].set_Value((long) rType); BindingListView<Role> view = new BindingListView<Role>(); foreach (System.Data.DataRow row in DALSql.ExecuteDataTable(this.SelectQuery + " where TypeId = @type", parameters).Rows) { Role owid = new Role(); this.Load(row, owid); view.Add(owid); } return view; }
public BindingListView<Role> FindIncludeRolesBy(User user) { System.Data.SqlClient.SqlParameter[] parameters = new System.Data.SqlClient.SqlParameter[] { new System.Data.SqlClient.SqlParameter("@name", System.Data.SqlDbType.VarChar) }; parameters[0].set_Value(user.Login); string sql = this.RoleSelectQuery + " \t\tinner join sys.database_role_members rm on t.id = rm.role_principal_id\r\n\t\t inner join sys.database_principals pr on rm.member_principal_id = pr.principal_id\r\n where pr.type='S' and t.typeRole in ('РОЛЬ') and pr.[name] = @name"; BindingListView<Role> view = new BindingListView<Role>(); foreach (System.Data.DataRow row in DALSql.ExecuteDataTable(sql, parameters).Rows) { Role owid = new Role(); this.Load(row, owid); view.Add(owid); } return view; }
public BindingListView<Role> FindIncludeRolesBy(Role role) { System.Data.SqlClient.SqlParameter[] parameters = new System.Data.SqlClient.SqlParameter[] { new System.Data.SqlClient.SqlParameter("@id", System.Data.SqlDbType.BigInt) }; parameters[0].set_Value((int) role.Id); string sql = this.SelectQuery + " inner join sn.RightGroups rg on rg.RightId = t.id\r\n where\trg.GroupId = @id"; BindingListView<Role> view = new BindingListView<Role>(); foreach (System.Data.DataRow row in DALSql.ExecuteDataTable(sql, parameters).Rows) { Role owid = new Role(); this.Load(row, owid); view.Add(owid); } return view; }
public BindingListView<Role> FindIncludeRightsBy(User user) { System.Data.SqlClient.SqlParameter[] parameters = new System.Data.SqlClient.SqlParameter[] { new System.Data.SqlClient.SqlParameter("@userId", System.Data.SqlDbType.BigInt) }; parameters[0].set_Value((long) user.Id); string sql = this.SelectQuery + "\tinner join sn.UserRights ur on ur.RightId = t.id\r\n\tinner join sn.Users u on ur.UserId = u.id\r\nwhere u.id = @userId and t.TypeId not in (select id from sn.RightTypes where [name] like 'Роль%')"; BindingListView<Role> view = new BindingListView<Role>(); foreach (System.Data.DataRow row in DALSql.ExecuteDataTable(sql, parameters).Rows) { Role owid = new Role(); this.Load(row, owid); view.Add(owid); } return view; }