Ejemplo n.º 1
0
        private void DGVMatContainer_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            BLWriteMiutes bLWrite = new BLWriteMiutes();

            if (DGVMatContainer.CurrentCell.OwningColumn.Name == ("Delete") && e.RowIndex != -1)
            {
                if (DGVMatContainer.CurrentCell.GetType() == typeof(DataGridViewButtonCell))
                {
                    bLWrite.DeleteMaterialeWithTransaction((Int32)DGVMatContainer.CurrentRow.Cells["Id_Materiale"].Value);
                    DGVMatContainer.DataSource = bLWrite.GetMateriale_Container();
                }
            }
            if (DGVMatContainer.CurrentCell.OwningColumn.Name == ("Pericoloso") && e.RowIndex != -1)
            {
                if (DGVMatContainer.CurrentCell.GetType() == typeof(DataGridViewCheckBoxCell))
                {
                    //((DataGridViewCheckBoxCell)DGVMatContainer.CurrentCell).Value
                    this.DGVMatContainer.CellValueChanged -= new System.Windows.Forms.DataGridViewCellEventHandler(this.CheckValueCell_Changed);
                    if (ValidateCurrentRow(DGVMatContainer.CurrentRow))
                    {
                        New_Row(null, null);
                    }
                }
            }
            button1.Visible = true;
        }
Ejemplo n.º 2
0
        private void TestGriglia_Load(object sender, EventArgs e)
        {
            FillCombo();
            BLWriteMiutes writeMinutes = new BLWriteMiutes();
            MinuteRow     minuteRow    = writeMinutes.getMinuteRow();

            csgray.BackColor          = Color.LightGray;
            csgray.SelectionBackColor = Color.LightGray;

            //csgray.Font = font;

            csOrange.BackColor          = Color.Orange;
            csOrange.SelectionBackColor = Color.Orange;
            //csOrange.Font = font;

            csWhite.BackColor          = Color.White;
            csWhite.SelectionBackColor = Color.White;
            //csWhite.Font = font;

            csDisabled.BackColor          = Color.DarkGray;
            csDisabled.SelectionBackColor = Color.DarkGray;

            //csDisabled.Font = font;
            DGVMatContainer.DataSource = writeMinutes.GetMateriale_Container();
            button1.Visible            = true;
        }
Ejemplo n.º 3
0
        private void DGVMatContainer_CellEndEdit(object sender, DataGridViewCellEventArgs e)
        {
            BLWriteMiutes bLWrite = new BLWriteMiutes();

            if (ValidateCurrentRow(((DataGridView)sender).CurrentRow))
            {
                New_Row(sender, new DataGridViewRowEventArgs(DGVMatContainer.CurrentRow));
                DGVMatContainer.AllowUserToAddRows = false;
                this.DGVMatContainer.CellEndEdit  -= new System.Windows.Forms.DataGridViewCellEventHandler(this.DGVMatContainer_CellEndEdit);
            }
        }
Ejemplo n.º 4
0
        private void Button1_Click(object sender, EventArgs e)
        {
            DGVMatContainer.ClearSelection();//If you want
            BLWriteMiutes bLWrite = new BLWriteMiutes();

            DGVMatContainer.DataSource = bLWrite.GetMateriale_Container();
            DGVMatContainer.Rows.OfType <DataGridViewRow>().Last().Selected = true;
            if (ValidateCurrentRow(DGVMatContainer.Rows.OfType <DataGridViewRow>().Last()))
            {
                LBLStatus.Visible = true;
                LBLStatus.Text    = "Updating.....";
                LBLStatus.Refresh();

                bLWrite.InsertMaterialeWithTransaction(0, "", "", "", "", "", "", "", false, "", "", "", "");
                DGVMatContainer.DataSource = bLWrite.GetMateriale_Container();
                LBLStatus.Visible          = false;
                LBLStatus.Text             = "Updating.....";
                LBLStatus.Refresh();
            }
            else
            {
                MessageBox.Show("Impossibile inserire altra riga");
            }
        }
Ejemplo n.º 5
0
        private void New_Row(object sender, DataGridViewRowEventArgs e)
        {
            try
            {
                DataGridViewRow dvrc = DGVMatContainer.CurrentRow;

                Dictionary <string, object> keyValuePair = new Dictionary <string, object>();
                foreach (DataGridViewCell cell in dvrc.Cells)
                {
                    //rowValues[cell.ColumnIndex] = cell.Value;
                    if (cell.OwningColumn.Name != "Pericoloso")
                    {
                        keyValuePair.Add(cell.OwningColumn.Name, cell.Value);
                    }
                    else if (cell.GetType() == typeof(DataGridViewCheckBoxCell))

                    {
                        DataGridViewCheckBoxCell cellB = (DataGridViewCheckBoxCell)cell;
                        if ((bool)cellB.EditedFormattedValue == false)
                        {
                            keyValuePair.Add(cell.OwningColumn.Name, false);
                            cellB.Style = csDisabled;
                        }
                        else
                        {
                            keyValuePair.Add(cell.OwningColumn.Name, true);
                        }
                    }
                    else
                    if (cell.GetType() == typeof(DataGridViewComboBoxCell))

                    {
                        DataGridViewComboBoxCell cellB = (DataGridViewComboBoxCell)cell;

                        keyValuePair.Add(cell.OwningColumn.Name, cellB.Value);
                    }
                }

                object tempValue = null;
                //passeggero = Convert.ToInt32(rowValues[0]);
                keyValuePair.TryGetValue("Id_Materiale", out tempValue);
                Int32 idMateriale = Convert.ToInt32(tempValue);
                keyValuePair.TryGetValue("Quantita_Materiale", out tempValue);
                short qtaMateriale = Convert.ToInt16(tempValue);
                keyValuePair.TryGetValue("Descrizione_Materiale", out tempValue);
                string descMateriale = Convert.ToString(tempValue);
                keyValuePair.TryGetValue("Lunghezza_Materiale", out tempValue);
                string lungMateriale = Convert.ToString(tempValue);
                keyValuePair.TryGetValue("Altezza_Materiale", out tempValue);
                string altMateriale = Convert.ToString(tempValue);
                keyValuePair.TryGetValue("Profondita_Materiale", out tempValue);
                string profMateriale = Convert.ToString(tempValue);
                keyValuePair.TryGetValue("Peso_Materiale", out tempValue);
                string pesoMateriale = Convert.ToString(tempValue);
                keyValuePair.TryGetValue("Valore_Materiale", out tempValue);
                string ValoreMateriale = Convert.ToString(tempValue);
                keyValuePair.TryGetValue("Matricola", out tempValue);
                string Matricola = Convert.ToString(tempValue);

                keyValuePair.TryGetValue("Pericoloso", out tempValue);

                bool pericoloso = Convert.ToBoolean(tempValue);
                keyValuePair.TryGetValue("UN_Code", out tempValue);
                string unCode = Convert.ToString(tempValue);
                keyValuePair.TryGetValue("Classe_Rischio", out tempValue);
                string classeR = Convert.ToString(tempValue);
                keyValuePair.TryGetValue("Compatibilita", out tempValue);
                string compat = Convert.ToString(tempValue);
                keyValuePair.TryGetValue("Peso_Pericoloso", out tempValue);
                string pesoPericoloso = Convert.ToString(tempValue);

                BLWriteMiutes bLWrite = new BLWriteMiutes();



                LBLStatus.Visible = true;
                LBLStatus.Text    = "Updating.....";
                LBLStatus.Refresh();


                if (bLWrite.updateMaterialeWithTransaction(idMateriale, qtaMateriale, Matricola, descMateriale, ValoreMateriale, lungMateriale, altMateriale, profMateriale, pesoMateriale, pericoloso, pesoPericoloso, unCode, classeR, compat))
                {
                    DGVMatContainer.DataSource = bLWrite.GetMateriale_Container();

                    DGVMatContainer.CurrentCell = DGVMatContainer.Rows.OfType <DataGridViewRow>().Last().Cells.OfType <DataGridViewCell>().ElementAt(2);
                    //DGVMatContainer.AllowUserToAddRows = false;
                    this.DGVMatContainer.CellValueChanged += new System.Windows.Forms.DataGridViewCellEventHandler(this.CheckValueCell_Changed);
                    this.DGVMatContainer.CellEndEdit      += new System.Windows.Forms.DataGridViewCellEventHandler(this.DGVMatContainer_CellEndEdit);
                    LBLStatus.Visible = false;
                    LBLStatus.Text    = "Updating.....";
                    LBLStatus.Refresh();
                }
                else
                {
                    int i = 0;


                    DGVMatContainer.AllowUserToAddRows = false;
                    DGVMatContainer.Rows.OfType <DataGridViewRow>().Last().Selected = true;

                    this.DGVMatContainer.CellValueChanged += new System.Windows.Forms.DataGridViewCellEventHandler(this.CheckValueCell_Changed);
                    MessageBox.Show("Check reuqired");

                    return;
                }
            }
            catch (Exception ex) { }
        }