/// <summary>
        /// Handles invocation of RowMouseLeave events
        /// </summary>
        internal void DoRowMouseLeaveEvent(GridRow gridRow)
        {
            if (RowMouseLeave != null)
            {
                GridRowEventArgs ev = new
                    GridRowEventArgs(gridRow.GridPanel, gridRow);

                RowMouseLeave(this, ev);
            }
        }
Exemple #2
0
        public frmGridViews()
        {
            InitializeComponent();

            Icon = Properties.Resources.logo;

            DataSet ds = Program.DB.SelectAll("SELECT ID,Name,IsZone FROM Rooms;");
            Dictionary<int, string> zones = new Dictionary<int, string>();
            if (ds.Tables.Count > 0)
            {
                TreeNode tnRoot = new TreeNode();

                foreach (DataRow dr in ds.Tables[0].Rows)
                {
                    if (dr["IsZone"] != DBNull.Value && dr["IsZone"].Equals("Y"))
                    {
                        zones.Add(Convert.ToInt32(dr["ID"]), dr["Name"].ToString());
                    }
                }

                foreach (DataRow dr in ds.Tables[0].Rows)
                {
                    if (dr["IsZone"] != DBNull.Value && dr["IsZone"].Equals("Y"))
                    {
                        tv.Nodes.Add(dr["Name"].ToString().Replace("|", " - "));
                        tnRoot = tv.Nodes[tv.Nodes.Count - 1];
                        tnRoot.Tag = dr["ID"];
                    }
                    else if (dr["IsZone"] != DBNull.Value && dr["IsZone"].Equals("B"))
                    {
                        tv.Nodes.Add(dr["Name"].ToString().Replace("|", " - "));
                        tv.Nodes[tv.Nodes.Count - 1].Tag = dr["ID"];
                    }
                    else
                    {
                        tnRoot.Nodes.Add(dr["Name"].ToString());
                        tnRoot.Nodes[tnRoot.Nodes.Count - 1].Tag = dr["ID"];
                    }
                }
            }

            tv.ExpandAll();

            ds = Program.DB.SelectAll("SELECT * FROM WorkSheets;");
            if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
            {
                foreach (DataRow dr in ds.Tables[0].Rows)
                {
                    DateTime dtS = Convert.ToDateTime(dr["Start"].ToString()), dtF = Convert.ToDateTime(dr["Finish"].ToString());

                    GridRow r = new GridRow(new object[] {
                        dr["ID"].ToString(), dr["Name"].ToString(), dtS.Date.ToShortDateString(), dtF.Date.ToShortDateString()
                    });
                    r.Tag = dr["ID"];
                    g.PrimaryGrid.Rows.Add(r);
                }
            }
        }
        private void gridZakazky_RowDoubleClick(object sender, DevComponents.DotNetBar.SuperGrid.GridRowDoubleClickEventArgs e)
        {
            DevComponents.DotNetBar.SuperGrid.GridRow selectedRow = (DevComponents.DotNetBar.SuperGrid.GridRow)e.GridRow;
            int cisloZakazky = Convert.ToInt32(selectedRow.Cells[1].Value);

            Properties.Settings.Default.CisloZakazky = cisloZakazky;
            Properties.Settings.Default.Save();
            if (System.Windows.Forms.Application.OpenForms["EditZakazky"] as EditZakazky != null)
            {
                MessageBox.Show("Formulár úprava zákazky je už otvorený");
            }
            else
            {
                EditZakazky EditZakazky = new EditZakazky();
                EditZakazky.ShowDialog();
            }
        }
        /// <summary>
        /// Handles invocation of RowValidating events
        /// </summary>
        internal bool DoRowValidatingEvent(GridRow gridRow)
        {
            if (RowValidating != null)
            {
                GridRowValidatingEventArgs ev = new
                    GridRowValidatingEventArgs(gridRow.GridPanel, gridRow);

                RowValidating(this, ev);

                return (ev.Cancel);
            }

            return (false);
        }
Exemple #5
0
        private void anadir_tmtos_Click(object sender, EventArgs e)
        {
            GridRow tupla = (GridRow)sgrid_tmtos.ActiveRow;

            if (tupla != null)
            {
                if (sgrid_tmtos2.PrimaryGrid.Columns.Count == 0)
                {
                    GridColumnCollection columnas = sgrid_tmtos.PrimaryGrid.Columns;
                    foreach (GridColumn columna in columnas)
                        sgrid_tmtos2.PrimaryGrid.Columns.Add(new GridColumn(columna.Name));
                }

                GridCellCollection c = tupla.Cells;

                if(!esta_agregado(c[0].ToString()))
                {
                    GridRow nueva = new GridRow(c[0].Value.ToString(),c[1].Value.ToString(),c[2].Value.ToString(),c[3].Value.ToString(),
                                                c[4].Value.ToString(),c[5].Value.ToString(),c[6].Value.ToString());

                    sgrid_tmtos2.PrimaryGrid.Rows.Add((GridElement)nueva);
                }
                else
                    mensaje_error("Ya se ha agregado el mismo medicamento.");
            }
        }
Exemple #6
0
        private void modifica_t_Click_1(object sender, EventArgs e)
        {
            GridRow tupla = (GridRow)sgrid_tratamientos.ActiveRow;

            if (tupla != null)
            {
                GridCellCollection tratamiento = tupla.Cells;
                List<String> ids_med = new List<string>();

                codigo_tm = tratamiento[0].Value.ToString();
                nombre_t.Text = tratamiento[1].Value.ToString();
                descripcion_t.Text = tratamiento[2].Value.ToString();
                sgrid_tmtos2.PrimaryGrid.Rows.Clear();

                if (sgrid_tmtos2.PrimaryGrid.Columns.Count == 0)
                {
                    GridColumnCollection columnas = sgrid_tmtos.PrimaryGrid.Columns;
                    foreach (GridColumn columna in columnas)
                        sgrid_tmtos2.PrimaryGrid.Columns.Add(new GridColumn(columna.Name));
                }

                med_aux = new List<string>();

                foreach (GridRow medicamento in sgrid_det_med.PrimaryGrid.Rows)
                {
                    GridCellCollection m = medicamento.Cells;
                    med_aux.Add(m[1].Value.ToString());
                    GridRow nueva = new GridRow(m[1].Value.ToString(),"", m[2].Value.ToString(), m[3].Value.ToString(), m[4].Value.ToString(),
                                                m[5].Value.ToString(), m[6].Value.ToString());

                    sgrid_tmtos2.PrimaryGrid.Rows.Add((GridElement)nueva);
                }

                sgrid_det_med.PrimaryGrid.Rows.Clear();
                alta_t.Text = "Confirmar";
                stc_tratamiento.SelectedTab = sti_control_t;
                modifica_tm = true;
            }
        }
Exemple #7
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            int i;

            if (txtName.Text.Trim().Length == 0)
            {
                MessageBox.Show("Please enter a grid view name to continue.", "Grid View Name", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                return;
            }
            else if (!bDateStartChosen)
            {
                MessageBox.Show("Please select a start date to continue.", "Start Date", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                return;
            }
            else if (!bDateFinishChosen)
            {
                MessageBox.Show("Please select a finish date to continue.", "Finish Date", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                return;
            }

            string sRooms = "";
            int iRooms = 0;
            foreach (TreeNode n in tv.Nodes)
            {
                if (n.Checked && n.Nodes.Count > 0)
                {
                    sRooms += sRooms.Length > 0 ? "," + n.Tag : n.Tag;
                    iRooms++;

                    foreach (TreeNode nc in n.Nodes)
                    {
                        if (nc.Checked)
                        {
                            sRooms += sRooms.Length > 0 ? "," + nc.Tag : nc.Tag;
                            iRooms++;
                        }
                    }
                }
                else if (n.Checked)
                {
                    sRooms += sRooms.Length > 0 ? "," + n.Tag : n.Tag;
                    iRooms++;
                }
            }

            if (iRooms == 0)
            {
                MessageBox.Show("Please choose some rooms to continue.", "Rooms", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
            }

            Program.DB.AddParameter("Name", txtName.Text);
            Program.DB.AddParameter("Start", Convert.ToDateTime(dtFrom.Text));
            Program.DB.AddParameter("Finish", Convert.ToDateTime(dtTo.Text));
            Program.DB.AddParameter("Rooms", sRooms);

            if (iID > 0)
            {
                Program.DB.AddParameter("ID", iID);
                i = Program.DB.Update("UPDATE WorkSheets SET Name=@Name,Rooms=@Rooms,Start=@Start,Finish=@Finish WHERE ID=@ID;");
                if (i < 1)
                {
                    MessageBox.Show("The update failed. Please try again.", "Failed", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                else
                {
                    MessageBox.Show("The update was successful.", "Updated", (MessageBoxButtons.OK), (MessageBoxIcon.Information));
                }
            }
            else
            {
                i = Program.DB.Insert("INSERT INTO WorkSheets (Name,Rooms,Start,Finish) VALUES (@Name,@Rooms,@Start,@Finish)");
                if (i < 1)
                {
                    MessageBox.Show("The addition failed. Please try again.", "Failed", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                else
                {
                    MessageBox.Show("The addition was successful.", "Updated", (MessageBoxButtons.OK), (MessageBoxIcon.Information));
                }
            }

            iID = 0;
            txtName.Text = "";
            dtFrom.Text = "";
            dtTo.Text = "";
            foreach (TreeNode n in tv.Nodes)
            {
                n.Checked = false;
                if (n.Nodes.Count > 0)
                {
                    foreach (TreeNode nc in n.Nodes)
                    {
                        nc.Checked = false;
                    }
                }
            }
            txtName.Enabled = false;
            dtFrom.Enabled = false;
            dtTo.Enabled = false;
            tv.Enabled = false;
            btnCancel.Enabled = false;
            btnSave.Enabled = false;
            bDateStartChosen = false;
            bDateFinishChosen = false;
            g.Enabled = true;

            g.PrimaryGrid.Rows.Clear();
            DataSet ds = Program.DB.SelectAll("SELECT * FROM WorkSheets;");
            if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
            {
                foreach (DataRow dr in ds.Tables[0].Rows)
                {
                    DateTime dtS = Convert.ToDateTime(dr["Start"].ToString()), dtF = Convert.ToDateTime(dr["Finish"].ToString());

                    GridRow r = new GridRow(new object[] {
                        dr["ID"].ToString(), dr["Name"].ToString(), dtS.Date.ToShortDateString(), dtF.Date.ToShortDateString()
                    });
                    r.Tag = dr["ID"];
                    g.PrimaryGrid.Rows.Add(r);
                }
            }

            bDataChanged = true;
        }
        /// <summary>
        /// Handles invocation of RowDoubleClick events
        /// </summary>
        internal bool DoRowDoubleClickEvent(GridRow row, RowArea rowArea, MouseEventArgs e)
        {
            if (RowDoubleClick != null)
            {
                GridRowDoubleClickEventArgs ev = new
                    GridRowDoubleClickEventArgs(row.GridPanel, row, rowArea, e);

                RowDoubleClick(this, ev);

                return (ev.Cancel);
            }

            return (false);
        }
            private GridRow AllocNewGridRow(int index)
            {
                GridPanel panel = _Container.GridPanel;

                if (panel != null)
                {
                    GridRow row = new GridRow();

                    row.Parent = _Container;

                    row.GridIndex = index;
                    row.Index = index;
                    row.RowIndex = index;
                    row.FullIndex = index;

                    row.Loading = true;

                    try
                    {
                        GridColumnCollection columns = panel.Columns;

                        if (columns.Count > 0)
                        {
                            for (int i = 0; i < columns.Count; i++)
                            {
                                GridColumn col = panel.Columns[i];

                                GridCell cell = new GridCell(col.DefaultNewRowCellValue);

                                cell.Parent = row;
                                cell.ColumnIndex = i;

                                row.Cells.Add(cell);
                            }
                        }

                        ArrangeRow(panel, row);

                        if (columns.Count > 0)
                            _Container.SuperGrid.DoLoadVirtualRowEvent(panel, row);
                    }
                    finally
                    {
                        row.Loading = false;
                    }

                    return (row);
                }

                return (null);
            }
Exemple #10
0
        private void mRemove_Click(object sender, EventArgs e)
        {
            if (row != null && row.Tag != null && Convert.ToInt32(row.Tag) > 0)
            {
                Program.DB.AddParameter("ID", Convert.ToInt32(row.Tag));
                int i = Program.DB.Delete("DELETE FROM WorkSheets WHERE ID=@ID;");
                if (i < 1)
                {
                    MessageBox.Show("The removal failed. Please try again.", "Failed", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                else
                {
                    MessageBox.Show("The removal was successful.", "Updated", (MessageBoxButtons.OK), (MessageBoxIcon.Information));
                }

                g.PrimaryGrid.Rows.Clear();
                DataSet ds = Program.DB.SelectAll("SELECT * FROM WorkSheets;");
                if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
                {
                    foreach (DataRow dr in ds.Tables[0].Rows)
                    {
                        DateTime dtS = Convert.ToDateTime(dr["Start"].ToString()), dtF = Convert.ToDateTime(dr["Finish"].ToString());

                        GridRow r = new GridRow(new object[] {
                        dr["ID"].ToString(), dr["Name"].ToString(), dtS.Date.ToShortDateString(), dtF.Date.ToShortDateString()
                    });
                        r.Tag = dr["ID"];
                        g.PrimaryGrid.Rows.Add(r);
                    }
                }

                bDataChanged = true;
            }
        }
Exemple #11
0
        private void btnCommentSave_Click(object sender, EventArgs e)
        {
            if (txtComment.Text.Trim().Length > 0)
            {
                if (rComment != null && rComment.Tag.ToString() != "")
                {
                    rComment.Cells[2].Value = txtComment.Text.Trim();
                    gComments.PrimaryGrid.Rows[rComment.Index] = rComment;
                }
                else
                {
                    GridRow r = new GridRow(new object[] {
                        DateTime.Now.ToString(), Program.Global.UserFirstName + " " + Program.Global.UserLastName, txtComment.Text.Trim()
                    });
                    gComments.PrimaryGrid.Rows.Add(r);
                }
            }

            rComment = null;
            txtComment.Text = "";
            txtComment.Enabled = false;
            btnCommentSave.Enabled = false;
            btnCommentCancel.Enabled = false;
            gComments.Enabled = true;
        }
Exemple #12
0
 private void gComments_RowActivated(object sender, GridRowActivatedEventArgs e)
 {
     rComment = e.NewActiveRow as GridRow;
 }
        /// <summary>
        /// Handles invocation of RowSetDefaultValues events
        /// </summary>
        internal void DoRowSetDefaultValuesEvent(
            GridPanel panel, GridRow row, NewRowContext context)
        {
            if (RowSetDefaultValues != null)
            {
                GridRowSetDefaultValuesEventArgs ev = new
                    GridRowSetDefaultValuesEventArgs(panel, row, context);

                bool loading = row.Loading;
                row.Loading = true;

                try
                {
                    RowSetDefaultValues(this, ev);
                }
                finally
                {
                    row.Loading = loading;
                }
            }
        }
Exemple #14
0
        private void MeasureCell(GridLayoutInfo layoutInfo, GridLayoutStateInfo stateInfo,
            ColumnAutoSizeMode autoSizeMode, GridRow row, GridCell cell)
        {
            if (cell.NeedsMeasured || NeedsMeasured || row.NeedsMeasured)
            {
                int rowHeight = row.GetRowHeight();

                if (rowHeight > 0)
                {
                    Size size = new Size(Width, rowHeight);

                    if (autoSizeMode != ColumnAutoSizeMode.None)
                    {
                        cell.Measure(layoutInfo, stateInfo, Size.Empty);

                        size.Width = cell.Size.Width;
                        size.Width += GetColumnIndent(stateInfo.IndentLevel);
                    }
                    else
                    {
                        cell.Measure(layoutInfo, stateInfo, size);
                    }

                    cell.Size = size;
                }
                else
                {
                    Size size = Size.Empty;

                    if (autoSizeMode == ColumnAutoSizeMode.None)
                    {
                        size.Width = Width;
                        size.Width -= GetColumnIndent(stateInfo.IndentLevel);
                        size.Width = Math.Max(1, size.Width);
                    }

                    cell.Measure(layoutInfo, stateInfo, new Size(size.Width, 0));

                    if (autoSizeMode != ColumnAutoSizeMode.None)
                    {
                        size = cell.Size;
                        size.Width += GetColumnIndent(stateInfo.IndentLevel);
                        cell.Size = size;
                    }
                    else
                    {
                        size = cell.Size;
                        size.Width = Width;
                        cell.Size = size;
                    }
                }

                cell.CellSize = cell.Size;
            }
        }
        /// <summary>
        /// Handles invocation of RowMoving events
        /// </summary>
        internal bool DoRowMovingEvent(GridRow gridRow,
            GridContainer srcCont, int srcIndex, ref GridContainer destCont, ref int destIndex)
        {
            if (RowMoving != null)
            {
                GridRowMovingEventArgs ev = new GridRowMovingEventArgs(
                    gridRow.GridPanel, gridRow, srcCont, srcIndex, destCont, destIndex);

                RowMoving(this, ev);

                destIndex = ev.DestIndex;
                destCont = ev.DestContainer;

                return (ev.Cancel);
            }

            return (false);
        }
        /// <summary>
        /// Handles invocation of RowMouseUp events
        /// </summary>
        internal void DoRowMouseUpEvent(GridRow gridRow, MouseEventArgs args, RowArea area)
        {
            if (RowMouseUp != null)
            {
                GridRowMouseEventArgs ev = new
                    GridRowMouseEventArgs(gridRow.GridPanel, gridRow, args, area);

                RowMouseUp(this, ev);
            }
        }
        /// <summary>
        /// Handles invocation of RowGetDetailHeight events
        /// </summary>
        internal void DoRowGetDetailHeightEvent(GridRow row, 
            GridLayoutInfo layoutInfo, Size sizeNeeded, ref int preHeight, ref int postHeight)
        {
            if (GetDetailRowHeight != null)
            {
                GridGetDetailRowHeightEventArgs ev = new
                    GridGetDetailRowHeightEventArgs(row.GridPanel, row, layoutInfo, sizeNeeded, preHeight, postHeight);

                GetDetailRowHeight(this, ev);

                preHeight = ev.PreDetailHeight;
                postHeight = ev.PostDetailHeight;
            }
        }
        /// <summary>
        /// Handles invocation of RowInfoDoubleClick events
        /// </summary>
        internal void DoRowInfoDoubleClickEvent(GridRow gridRow, MouseEventArgs e)
        {
            if (RowInfoDoubleClick != null)
            {
                GridRowDoubleClickEventArgs ev = new
                    GridRowDoubleClickEventArgs(gridRow.GridPanel, gridRow, RowArea.InRowInfo, e);

                RowInfoDoubleClick(this, ev);
            }
        }
        /// <summary>
        /// Handles invocation of RowInfoEnter events
        /// </summary>
        internal bool DoRowInfoEnterEvent(GridRow gridRow, Point pt)
        {
            if (RowInfoEnter != null)
            {
                GridRowInfoEnterEventArgs ev = new
                    GridRowInfoEnterEventArgs(gridRow.GridPanel, gridRow, pt);

                RowInfoEnter(this, ev);

                return (ev.Cancel);
            }

            return (false);
        }
Exemple #20
0
        private Size GetMaxRowCellSize(GridRow row,
            GridLayoutInfo layoutInfo, GridLayoutStateInfo layoutState)
        {
            if (row.Cells.Count <= ColumnIndex)
                return (Size.Empty);

            GridCell cell = row.Cells[ColumnIndex];

            Size oldSize = cell.Size;

            cell.Measure(layoutInfo, layoutState, Size.Empty);

            Size size = cell.Size;
            size.Width += GetColumnIndent(layoutState.IndentLevel);

            cell.Size = oldSize;

            if (row.Rows.Count > 0 && row.Expanded == true)
            {
                layoutState.IndentLevel++;

                foreach (GridContainer item in row.Rows)
                {
                    if (item is GridRow)
                    {
                        Size cellSize =
                            GetMaxRowCellSize((GridRow)item, layoutInfo, layoutState);

                        size.Width = Math.Max(size.Width, cellSize.Width);
                        size.Height = Math.Max(size.Height, cellSize.Height);
                    }
                }

                layoutState.IndentLevel--;
            }

            return (size);
        }
        /// <summary>
        /// Handles invocation of RowValidated events
        /// </summary>
        internal void DoRowValidatedEvent(GridRow gridRow)
        {
            if (RowValidated != null)
            {
                GridRowValidatedEventArgs ev = new
                    GridRowValidatedEventArgs(gridRow.GridPanel, gridRow);

                RowValidated(this, ev);
            }
        }
Exemple #22
0
        public frmBooking()
        {
            InitializeComponent();

            Icon = Properties.Resources.logo;

            for (int i = 1; i < 201; i++)
            {
                cbxDelegates.Items.Add(i.ToString());
                cbxLunchAttendees.Items.Add(i.ToString());
            }

            DataSet ds = Program.DB.SelectAll("SELECT ID,Name FROM Companies;");
            if (ds.Tables.Count > 0)
            {
                AutoCompleteStringCollection asCompanies = new AutoCompleteStringCollection();
                foreach (DataRow dr in ds.Tables[0].Rows)
                {
                    asCompanies.Add(dr["Name"].ToString().Trim());
                }
                txtCompany.AutoCompleteCustomSource = asCompanies;
            }

            ds = Program.DB.SelectAll("SELECT ID,Name,IsZone FROM Rooms;");
            Dictionary<int, string> zones = new Dictionary<int, string>();
            if (ds.Tables.Count > 0)
            {
                TreeNode tnRoot = new TreeNode();

                foreach (DataRow dr in ds.Tables[0].Rows)
                {
                    if (dr["IsZone"] != DBNull.Value && dr["IsZone"].Equals("Y"))
                    {
                        zones.Add(Convert.ToInt32(dr["ID"]), dr["Name"].ToString());
                    }
                }

                foreach (DataRow dr in ds.Tables[0].Rows)
                {
                    if (dr["IsZone"] != DBNull.Value && dr["IsZone"].Equals("Y"))
                    {
                        tvRooms.Nodes.Add(dr["Name"].ToString().Replace("|", " - "));
                        tnRoot = tvRooms.Nodes[tvRooms.Nodes.Count - 1];
                        tnRoot.Tag = dr["ID"];
                    }
                    else if (dr["IsZone"] != DBNull.Value && dr["IsZone"].Equals("B"))
                    {
                        tvRooms.Nodes.Add(dr["Name"].ToString().Replace("|", " - "));
                        tvRooms.Nodes[tvRooms.Nodes.Count - 1].Tag = dr["ID"];
                    }
                    else
                    {
                        tnRoot.Nodes.Add(dr["Name"].ToString());
                        tnRoot.Nodes[tnRoot.Nodes.Count - 1].Tag = dr["ID"];
                    }
                }
            }

            if (SharedData.iBookingID > 0)
            {
                Text = "Edit Booking";

                //iNextID = SharedData.iBookingID;
                ds = Program.DB.SelectAll("SELECT ID,Job,BUser,BUserMod,BName,BCompany,BContact,BPhone,BEmail,BRoom,BRoomLayout,BDates,BTimes,BTimesAccess,BDelegates,BEquipment,BRefreshments,BRefreshmentsTimes,BLunch,BLunchMenu,BLunchNumber,BLunchTime,BLunchDiet,BComments,BInvoiceAddress,BInvoicePayment,BInvoiceOrder,Confirmed FROM Jobs WHERE ID=" + SharedData.iBookingID);
                if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
                {
                    DataRow row = ds.Tables[0].Rows[0];
                    if (row.ItemArray.Length > 0)
                    {
                        iNextID = Convert.ToInt32(row["Job"]);

                        DataSet d;
                        if (row["BCompany"] != DBNull.Value && row["BCompany"].ToString().All(char.IsDigit))
                        {
                            d = Program.DB.SelectAll("SELECT Name FROM Companies WHERE ID=" + row["BCompany"].ToString() + ";");
                            if (d.Tables.Count > 0 && d.Tables[0].Rows.Count > 0)
                            {
                                txtCompany.Text = d.Tables[0].Rows[0]["Name"].ToString();
                            }
                        }

                        if (txtCompany.Text.Trim() != "" && row["BContact"] != DBNull.Value && row["BContact"].ToString().All(char.IsDigit))
                        {
                            AutoCompleteStringCollection asContacts = new AutoCompleteStringCollection();
                            Program.DB.AddParameter("Company", row["BCompany"].ToString());
                            d = Program.DB.SelectAll("SELECT ID,NameTitle,NameFirst,NameLast FROM Contacts WHERE Company=@Company;");
                            if (d.Tables.Count > 0 && d.Tables[0].Rows.Count > 0)
                            {
                                string sSelected = "";
                                foreach (DataRow r in d.Tables[0].Rows)
                                {
                                    asContacts.Add(r["NameFirst"].ToString() + " " + r["NameLast"].ToString());
                                    if (r["ID"] == row["BContact"])
                                    {
                                        sSelected = r["NameFirst"].ToString() + " " + r["NameLast"].ToString();
                                    }
                                }
                                txtContact.AutoCompleteCustomSource = asContacts;
                                txtContact.Text = sSelected;
                            }
                        }

                        txtPhone.Text = row["BPhone"].ToString();
                        txtEmail.Text = row["BEmail"].ToString();

                        if (row["BRoom"] != DBNull.Value && row["BRoom"].ToString() != "")
                        {
                            string[] sRooms = row["BRoom"].ToString().Split(new char[] { '|' }, StringSplitOptions.RemoveEmptyEntries);
                            foreach (TreeNode n in tvRooms.Nodes)
                            {
                                if (n.Nodes.Count > 0)
                                {
                                    foreach (TreeNode nc in n.Nodes)
                                    {
                                        if (sRooms.Contains(nc.Tag.ToString()))
                                        {
                                            nc.Checked = true;
                                        }
                                    }
                                }
                                if (sRooms.Contains(n.Tag.ToString()))
                                {
                                    n.Checked = true;
                                }
                            }
                            tvRooms.ExpandAll();
                            tvRooms.TopNode = tvRooms.Nodes[0];
                        }

                        txtLayout.Text = row["BRoomLayout"].ToString();
                        txtName.Text = row["BName"].ToString();

                        DateTime now = DateTime.Now;
                        int iYear = now.Year, iMonth = now.Month, iDay = now.Day;

                        string[] dates;
                        if (row["BDates"].ToString() != "")
                        {
                            dates = row["BDates"].ToString().Split('|');
                            if (dates.Length == 2)
                            {
                                string[] d1 = dates[0].Split('/');
                                iYear = Convert.ToInt32(d1[2].Substring(0, d1[2].IndexOf(' ')));
                                iMonth = Convert.ToInt32(d1[1]);
                                iDay = Convert.ToInt32(d1[0]);
                                dtDateFrom.Value = new DateTime(iYear, iMonth, iDay);

                                string[] d2 = dates[1].Split('/');
                                iYear = Convert.ToInt32(d2[2].Substring(0, d2[2].IndexOf(' ')));
                                iMonth = Convert.ToInt32(d2[1]);
                                iDay = Convert.ToInt32(d2[0]);
                                dtDateTo.Value = new DateTime(iYear, iMonth, iDay);
                            }
                        }

                        string[] sTimes = row["BTimes"].ToString().Split('|');
                        if (sTimes.Length == 2)
                        {
                            dtTimeFrom.Text = sTimes[0];
                            dtTimeTo.Text = sTimes[1];
                        }
                        else
                        {
                            dtTimeFrom.Text = "";
                            dtTimeTo.Text = "";
                        }

                        sTimes = row["BTimesAccess"].ToString().Split('|');
                        if (sTimes.Length == 2)
                        {
                            dtTimeAccessFrom.Text = sTimes[0];
                            dtTimeAccessTo.Text = sTimes[1];
                        }
                        else
                        {
                            dtTimeAccessFrom.Text = "";
                            dtTimeAccessTo.Text = "";
                        }

                        cbxDelegates.SelectedIndex = cbxDelegates.FindStringExact(row["BDelegates"].ToString());
                        txtEquipment.Text = row["BEquipment"].ToString();

                        if (row["BRefreshments"] != DBNull.Value && row["BRefreshments"].ToString() == "Y")
                        {
                            swRefreshments.Value = true;
                        }
                        else
                        {
                            swRefreshments.Value = false;
                        }
                        txtRefreshmentTimes.Text = row["BRefreshmentsTimes"].ToString();

                        if (row["BLunch"] != DBNull.Value && row["BLunch"].ToString() == "Y")
                        {
                            swLunch.Value = true;
                        }
                        else
                        {
                            swLunch.Value = false;
                        }
                        txtLunchMenu.Text = row["BLunchMenu"].ToString();

                        cbxLunchAttendees.SelectedIndex = cbxLunchAttendees.FindStringExact(row["BLunchNumber"].ToString());
                        dtLunchTime.Text = row["BLunchTime"].ToString().Length > 0 ? row["BLunchTime"].ToString() : "";
                        txtLunchDiet.Text = row["BLunchDiet"].ToString();

                        d = Program.DB.SelectAll("SELECT ID,Entered,UserID,Comment FROM Comments WHERE Job=" + iNextID + ";");
                        if (d.Tables.Count > 0 && d.Tables[0].Rows.Count > 0)
                        {
                            foreach (DataRow r in d.Tables[0].Rows)
                            {
                                string sUser = "";
                                if (r["UserID"] != DBNull.Value && r["UserID"].ToString() != "")
                                {
                                    DataSet du = Program.DB.SelectAll("SELECT NameFirst,NameLast FROM Users WHERE ID=" + r["UserID"].ToString() + ";");
                                    if (du.Tables.Count > 0 && du.Tables[0].Rows.Count > 0)
                                    {
                                        sUser = du.Tables[0].Rows[0]["NameFirst"].ToString() + " " + du.Tables[0].Rows[0]["NameFirst"].ToString();
                                    }
                                }

                                GridRow gr = new GridRow(new object[] { r["Entered"].ToString(), sUser, r["Comment"].ToString() });
                                gr.Tag = r["ID"];
                                gComments.PrimaryGrid.Rows.Add(gr);
                            }
                        }

                        txtInvoiceAddress.Text = row["BInvoiceAddress"].ToString();
                        foreach (DevComponents.Editors.ComboItem ci in cbxPaymentMethod.Items)
                        {
                            if (ci.Text == row["BInvoicePayment"].ToString())
                            {
                                cbxPaymentMethod.SelectedItem = ci;
                                break;
                            }
                        }
                        txtPurchaseOrder.Text = row["BInvoiceOrder"].ToString();

                        if (row["BUser"] != DBNull.Value && row["BUser"].ToString().All(char.IsDigit))
                        {
                            d = Program.DB.SelectAll("SELECT NameFirst,NameLast FROM Users WHERE ID=" + row["BUser"].ToString() + ";");
                            if (d.Tables.Count > 0 && d.Tables[0].Rows.Count == 1)
                            {
                                lblUsers.Text = "Added by: " + d.Tables[0].Rows[0]["NameFirst"].ToString() + " " + d.Tables[0].Rows[0]["NameLast"].ToString();
                                lblUsers.Visible = true;
                            }
                        }

                        if (row["BUserMod"] != DBNull.Value && row["BUserMod"].ToString().All(char.IsDigit))
                        {
                            d = Program.DB.SelectAll("SELECT NameFirst,NameLast FROM Users WHERE ID=" + row["BUserMod"].ToString() + ";");
                            if (d.Tables.Count > 0 && d.Tables[0].Rows.Count == 1)
                            {
                                lblUsers.Text += Environment.NewLine + "Last modified by: " + d.Tables[0].Rows[0]["NameFirst"].ToString() + " " + d.Tables[0].Rows[0]["NameLast"].ToString();
                                lblUsers.Visible = true;
                            }
                        }

                        Text = "Edit Booking: " + Convert.ToInt32(row["Job"]).ToString(sNextIDFormat);

                        Program.DB.AddParameter("Job", row["Job"]);
                        DataSet c = Program.DB.SelectAll("SELECT * FROM Comments WHERE Job=@Job;");
                        if (c.Tables.Count > 0 && c.Tables[0].Rows.Count > 0)
                        {
                            foreach (DataRow r in c.Tables[0].Rows)
                            {
                                string sUser = r["UserID"].ToString();
                                Program.DB.AddParameter("ID", r["UserID"]);
                                DataSet cu = Program.DB.SelectAll("SELECT NameFirst,NameLast FROM Users WHERE ID=@ID;");
                                if (cu.Tables.Count > 0 && cu.Tables[0].Rows.Count > 0)
                                {
                                    sUser = cu.Tables[0].Rows[0]["NameFirst"] + " " + cu.Tables[0].Rows[0]["NameFirst"];
                                }

                                GridRow cr = new GridRow(new object[] {
                                    r["Entered"].ToString(), sUser, r["Comment"].ToString()
                                });
                                cr.Tag = r["ID"];
                            }
                        }
                    }
                }

                string sPath = Properties.Settings.Default.PathToData + @"\Bookings\" + SharedData.iBookingID.ToString(sNextIDFormat);
                if (Directory.Exists(sPath))
                {
                    string[] sFiles = Directory.GetFiles(sPath);
                    foreach (string sFile in sFiles)
                    {
                        if (File.Exists(sFile))
                        {
                            FileInfo inf = new FileInfo(sFile);
                            ListViewItem i = new ListViewItem();
                            i.Tag = sFile;
                            i.Text = inf.Name;
                            lvDocuments.Items.Add(i);
                        }
                    }
                }
            }
            else
            {
                dtDateFrom.Value = SharedData.dtSelectedStart != DateTime.Today ? SharedData.dtSelectedStart : DateTime.Today;
                dtDateTo.Value = SharedData.dtSelectedFinish != DateTime.Today ? SharedData.dtSelectedFinish : DateTime.Today;

                if (SharedData.sBookingCompany != "")
                {
                    txtCompany.Text = SharedData.sBookingCompany;
                }
                if (SharedData.sBookingContact != "")
                {
                    txtContact.Text = SharedData.sBookingContact;
                }
                if (SharedData.sBookingEmail != "")
                {
                    txtEmail.Text = SharedData.sBookingEmail;
                }
                if (SharedData.sBookingPhone != "")
                {
                    txtPhone.Text = SharedData.sBookingEmail;
                }
                if (SharedData.sBookingRooms != "")
                {
                    string[] sRooms = SharedData.sBookingRooms.Split(new char[] { '|' }, StringSplitOptions.RemoveEmptyEntries);
                    foreach (TreeNode n in tvRooms.Nodes)
                    {
                        if (n.Nodes.Count > 0)
                        {
                            foreach (TreeNode nc in n.Nodes)
                            {
                                if (sRooms.Contains(nc.Tag.ToString()))
                                {
                                    nc.Checked = true;
                                }
                            }
                        }
                        if (sRooms.Contains(n.Tag.ToString()))
                        {
                            n.Checked = true;
                        }
                    }
                    tvRooms.ExpandAll();
                    tvRooms.TopNode = tvRooms.Nodes[0];
                }

                dtTimeFrom.Text = "08:30";
                dtTimeTo.Text = "16:30";
                dtTimeAccessFrom.Text = "08:00";
                dtTimeAccessTo.Text = "17:00";

                ds = Program.DB.SelectAll("SELECT MAX(Job) AS NextID FROM Jobs;");
                if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0 && ds.Tables[0].Rows[0]["NextID"] != DBNull.Value)
                {
                    iNextID = Convert.ToInt32(ds.Tables[0].Rows[0]["NextID"].ToString()) + 1;
                }
                else
                {
                    iNextID = 1;
                }

                foreach (TreeNode item in tvRooms.Nodes)
                {
                    item.Checked = false;
                }

                Text = "Add Booking: " + iNextID.ToString(sNextIDFormat);
            }
        }
        /// <summary>
        /// Handles invocation of LoadVirtualRow events
        /// </summary>
        internal void DoLoadVirtualRowEvent(GridPanel panel, GridRow row)
        {
            if (LoadVirtualRow != null)
            {
                GridVirtualRowEventArgs ev = new
                    GridVirtualRowEventArgs(panel, row, row.Index);

                LoadVirtualRow(this, ev);
            }
        }
Exemple #24
0
 private void mCommentsAdd_Click(object sender, EventArgs e)
 {
     rComment = null;
     txtComment.Text = "";
     txtComment.Enabled = true;
     gComments.Enabled = false;
     btnCommentSave.Enabled = true;
     btnCommentCancel.Enabled = true;
 }
        /// <summary>
        /// Handles invocation of StoreVirtualRow events
        /// </summary>
        internal void DoStoreVirtualRowEvent(GridPanel gridPanel, GridRow gridRow)
        {
            if (StoreVirtualRow != null)
            {
                GridVirtualRowEventArgs ev = new
                    GridVirtualRowEventArgs(gridPanel, gridRow, gridRow.Index);

                StoreVirtualRow(this, ev);
            }
        }
            private void ArrangeRow(GridPanel panel, GridRow row)
            {
                Rectangle r = panel.BoundsRelative;

                r.Y += (panel.FixedRowHeight - (panel.FrozenRowCount * panel.VirtualRowHeight));
                r.Y += (row.Index * panel.VirtualRowHeight);

                r.Size = new Size(panel.ColumnHeader.Size.Width, panel.VirtualRowHeight);

                _layoutInfo.ClientBounds = r;
                _stateInfo.GridPanel = panel;

                row.FixedRowHeight = r.Size.Height;
                row.Arrange(_layoutInfo, _stateInfo, r);
            }
Exemple #27
0
        private static bool EvalRowFilterState(
            GridPanel panel, GridRow row, ref bool filteredOut)
        {
            try
            {
                filteredOut = (panel.FilterEval.Evaluate(row) == false);
            }
            catch (Exception exp)
            {
                filteredOut = false;

                bool throwException = false;

                if (panel.SuperGrid.DoFilterRowErrorEvent(panel,
                    row, exp, ref filteredOut, ref throwException) == true)
                {
                    return (true);
                }

                if (throwException == true)
                    throw;

                MessageBoxEx.Show(exp.Message);

                return (true);
            }

            return (false);
        }
Exemple #28
0
 private void g_RowActivated(object sender, GridRowActivatedEventArgs e)
 {
     row = e.NewActiveRow as GridRow;
 }
Exemple #29
0
        private static bool EvalColumnFilterState(
            GridPanel panel, GridRow row, ref bool filteredOut)
        {
            foreach (GridColumn col in panel.Columns)
            {
                if (col.IsFiltered == true)
                {
                    if (col.FilterError == false)
                    {
                        try
                        {
                            filteredOut = (col.FilterEval.Evaluate(row) == false);
                        }
                        catch (Exception exp)
                        {
                            col.FilterError = true;

                            filteredOut = false;

                            bool throwException = false;

                            if (panel.SuperGrid.DoFilterColumnErrorEvent(panel,
                                row, col, exp, ref filteredOut, ref throwException) == true)
                            {
                                return (true);
                            }

                            if (throwException == true)
                                throw;

                            if (col.FilterEval.PostError == true)
                                MessageBoxEx.Show((col.Name ?? "[" + col.ColumnIndex + "]") + ":\n" + exp.Message);

                            return (true);
                        }
                    }
                }

                if (filteredOut == true)
                    break;
            }

            return (false);
        }
Exemple #30
0
        internal static void UpdateRowFilterState(GridPanel panel, GridRow row)
        {
            bool isPrimary = (row.Parent is GridPanel);

            bool root = (panel.FilterLevel &
                (FilterLevel.Root | FilterLevel.RootConditional)) != 0;

            bool expanded = (panel.FilterLevel & FilterLevel.Expanded) != 0;

            if ((isPrimary == true && root == true) ||
                (isPrimary == false && expanded == true))
            {
                bool filteredOut = false;

                bool rowFiltered = IsRowFiltered(panel);
                bool colFiltered = IsColumnFiltered(panel);

                if (rowFiltered == true || colFiltered == true)
                {
                    if (rowFiltered == true)
                        rowFiltered = UpdateRowFilter(panel);

                    if (colFiltered == true)
                        UpdateColumnFilter(panel);

                    if (rowFiltered == true)
                    {
                        if (EvalRowFilterState(panel, row, ref filteredOut) == true)
                            return;
                    }

                    if (filteredOut == false && colFiltered == true)
                    {
                        if (EvalColumnFilterState(panel, row, ref filteredOut) == true)
                            return;
                    }
                }

                row.RowFilteredOut = filteredOut;

                panel.SuperGrid.NeedToUpdateIndicees = true;
            }
        }
        /// <summary>
        /// Handles invocation of PreRenderRow events
        /// </summary>
        internal bool DoPreRenderRowEvent(Graphics g, 
            GridRow gridRow, RenderParts parts, Rectangle bounds)
        {
            if (PreRenderRow != null)
            {
                GridPreRenderRowEventArgs ev = new
                    GridPreRenderRowEventArgs(g, gridRow.GridPanel, gridRow, parts, bounds);

                PreRenderRow(this, ev);

                return (ev.Cancel);
            }

            return (false);
        }