Example #1
0
        private void cmbDatabase_DropDown(object sender, EventArgs e)
        {
            String CommandText = "SELECT name FROM sys.sysdatabases ORDER BY name";

            if (cmbDatabase.Items.Count > 0)
            {
                cmbDatabase.Items.Clear();
            }

            BuildConnStr();
            ConnectionBuilder.InitialCatalog = "master";
            try
            {
                Table.Clear();
                TransactionHandler.LoadData(CommandText, ref Table, null, ConnectionBuilder.ConnectionString);
            }
            catch (Exception ex)
            {
                IMessageHandler.ShowError(ex.Message);
            }

            foreach (DataRow row in Table.Rows)
            {
                cmbDatabase.Items.Add(row["name"]);
            }
        }
        public void CreateColumns()
        {
            ITransactionHandler VTransactionHandler = new ITransactionHandler();
            DataTable           dt = new DataTable();

            try
            {
                VTransactionHandler.LoadData(CommandText, ref dt, this.Parameters);

                foreach (DataColumn dc in dt.Columns)
                {
                    JkColumn column = new JkColumn();
                    column.Name       = dc.ColumnName;
                    column.Caption    = dc.ColumnName;
                    column.DataType   = IAppHandler.ConvertTypeToSqlType(dc.DataType);
                    column.Width      = 100;
                    column.FooterType = JkColumn.ColumnFooterTypes.ftNone;
                    if (dc.ColumnName.Contains("Id"))
                    {
                        column.Visible = false;
                    }

                    if (Columns.Find(col => col.Name == column.Name) == null)
                    {
                        _Columns.Add(column);
                    }
                }
            }
            finally
            {
                dt.Dispose();
            }
        }
        public void LoadData()
        {
            ITransactionHandler VTransactionHandler = new ITransactionHandler();

            dstMaster.DataTable.Clear();
            if (!String.IsNullOrWhiteSpace(dstMaster.CommandText))
            {
                dstMaster.DataTable = VTransactionHandler.LoadData(dstMaster.CommandText, dstMaster.Parameters);
            }

            dataGridView.DataSource          = dstMaster.DataTable;
            dataGridView.AutoGenerateColumns = false;

            foreach (DataGridViewColumn column in dataGridView.Columns)
            {
                column.ReadOnly = column.Index != 0;
            }
        }
        protected override void PerformOperation()
        {
            base.PerformOperation();

            JkDetailDataSet     dataset             = new JkDetailDataSet();
            JkFormParameter     param               = new JkFormParameter();
            ITransactionHandler VTransactionHandler = new ITransactionHandler();
            int SelectionIdIndex        = dataGridView.GetCellIndex("SelectionId");
            int ReportFilterTypeIdIndex = dataGridView.GetCellIndex("ReportFilterTypeId");
            int SelectedIndex           = dataGridView.GetCellIndex("Selected");

            dataset.CommandText =
                "SELECT Id, SystemUserId, ReportFilterTypeId, SelectionId " +
                "FROM tblReportFilter " +
                "WHERE SystemUserId = @SystemUserId";
            param.Name  = "SystemUserId";
            param.Value = ISecurityHandler.SecurityUserId.ToString();
            dataset.Parameters.Add(param);
            dataset.DataTable = VTransactionHandler.LoadData(dataset.CommandText, dataset.Parameters);
            foreach (DataRow row in dataset.DataTable.Rows)
            {
                row.Delete();
            }

            foreach (DataGridViewRow row in dataGridView.Rows)
            {
                if (bool.Parse(row.Cells[SelectedIndex].Value.ToString()))
                {
                    DataRow newRow = dataset.DataTable.NewRow();

                    newRow["SystemUserId"]       = ISecurityHandler.SecurityUserId;
                    newRow["ReportFilterTypeId"] = row.Cells[ReportFilterTypeIdIndex].Value;
                    newRow["SelectionId"]        = row.Cells[SelectionIdIndex].Value;
                    dataset.DataTable.Rows.Add(newRow);
                }
            }
            VTransactionHandler.Connect();
            VTransactionHandler.EditMaster(dataset.CommandText, dataset.Parameters);
            VTransactionHandler.Disconnect();
        }
Example #5
0
        private void CreateMasterColumns()
        {
            ITransactionHandler VTransactionHandler = new ITransactionHandler();
            DataTable           table = new DataTable();

            VTransactionHandler.LoadData(CommandText, ref table, this.Parameters);
            foreach (DataColumn dc in table.Columns)
            {
                if (!dc.AutoIncrement)
                {
                    JkMasterColumn column = new JkMasterColumn();
                    column.Name         = dc.ColumnName;
                    column.DataType     = IAppHandler.ConvertTypeToSqlType(dc.DataType);
                    column.Required     = !dc.AllowDBNull;
                    column.DefaultValue = IAppHandler.SetColumnsDefaultValue(dc.ColumnName);

                    if (MasterColumns.Find(col => col.Name == column.Name) == null)
                    {
                        _MasterColumns.Add(column);
                    }
                }
            }
        }