Ejemplo n.º 1
0
 private void initStatsGrid()
 {
     {
         DataGridViewColumn        col  = new DataGridViewColumn();
         DataGridViewTypedLinkCell cell = new DataGridViewTypedLinkCell();
         cell.SystemType  = EditorSystemType.Statistic;
         col.Name         = "statistic_def_id";
         col.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
         col.FillWeight   = 100;
         col.HeaderText   = "Statistic";
         col.CellTemplate = cell;
         gridStatistics.Columns.Add(col);
     }
     {
         DataGridViewNumericUpDownElements.DataGridViewNumericUpDownColumn col  = new DataGridViewNumericUpDownElements.DataGridViewNumericUpDownColumn();
         DataGridViewNumericUpDownElements.DataGridViewNumericUpDownCell   cell = new DataGridViewNumericUpDownElements.DataGridViewNumericUpDownCell();
         col.Name         = "value";
         col.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
         col.Width        = 50;
         col.HeaderText   = "Starting Value";
         col.CellTemplate = cell;
         col.Maximum      = 99999;
         col.Minimum      = -99999;
         gridStatistics.Columns.Add(col);
     }
     {
         DataGridViewCheckBoxColumn col  = new DataGridViewCheckBoxColumn();
         DataGridViewCheckBoxCell   cell = new DataGridViewCheckBoxCell();
         col.Name         = "is_exempt";
         col.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
         col.FillWeight   = 25;
         col.HeaderText   = "Is Exempt";
         col.CellTemplate = cell;
         gridStatistics.Columns.Add(col);
     }
 }
        ///*******************************************************************************
        ///NOMBRE DE LA FUNCIÓN: Habilita_Verticalmente
        ///DESCRIPCIÓN  : Habilita o deshabilita los checkbox del grid verticalmente.
        ///PARAMENTROS  : 1. Grid_Copia_Accesos, GridView del que se va habilitar o deshabilitar
        ///                                 los checkbox.
        ///               2. Columna, Indice que indica la columna del grid.
        ///               3. Fila, Indice que indica la fila del grid.
        ///               4. Valor, Variable boleana que establece si se habilita o deshabilita
        ///                                 el checkbox.
        ///               5. Condicion, Variable String que determina hasta donde avanzara
        ///                                 verticalmente.
        ///CREO         : Luis Alberto Salas Garcia
        ///FECHA_CREO   : 07/Mar/2013
        ///MODIFICO     :
        ///FECHA_MODIFICO:
        ///CAUSA_MODIFICACIÓN:
        ///*******************************************************************************
        private void Habilita_Verticalmente(DataGridView Grid_Copia_Accesos, int Columna, int Fila, bool Valor, String Condicion)
        {
            DataGridViewCheckBoxCell Check_Box_Cell = new DataGridViewCheckBoxCell();

            for (int i = Fila; i < Grid_Copia_Accesos.RowCount; i++)
            {
                if (Grid_Copia_Accesos.Rows[i].Cells[Columna] is DataGridViewCheckBoxCell)
                {
                    Check_Box_Cell = Grid_Copia_Accesos.Rows[i].Cells[Columna] as DataGridViewCheckBoxCell;
                    if (Grid_Copia_Accesos.Rows[i].Cells["TIPO"].Value.ToString().Equals(Condicion))
                    {
                        break;
                    }
                    else
                    {
                        Check_Box_Cell.Value = Valor;
                        if (Grid_Copia_Accesos.Columns[Columna].HeaderText.Equals("Habilitar"))
                        {
                            Habilita_Horizontalmente(Grid_Copia_Accesos, Columna + 1, i, Valor);
                        }
                    }
                }
            }
        }
Ejemplo n.º 3
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                List <Data_PaymentStaging> staging = new List <Data_PaymentStaging>();

                foreach (DataGridViewRow i in grdSuppliers.Rows)
                {
                    DataGridViewCheckBoxCell cell = i.Cells["Selected"] as DataGridViewCheckBoxCell;

                    bool isSelected = Convert.ToBoolean(cell.Value);

                    if (isSelected)
                    {
                        Data_Supplier supplier = i.DataBoundItem as Data_Supplier;

                        if (supplier != null)
                        {
                            staging.Add(new Data_PaymentStaging()
                            {
                                Username    = Global.Username,
                                SuppplierId = supplier.SupplierID,
                                Amount      = amount
                            });
                        }
                    }
                }

                Data_PaymentStaging.SavePaymentStaging(Global.Username, staging);
                DialogResult = DialogResult.OK;
            }
            catch (Exception ex)
            {
                Utils.ShowException(ex);
            }
        }
Ejemplo n.º 4
0
 private void initAbilitiesGrid()
 {
     {
         DataGridViewColumn        col  = new DataGridViewColumn();
         DataGridViewTypedLinkCell cell = new DataGridViewTypedLinkCell();
         cell.SystemType  = EditorSystemType.Ability;
         col.Name         = "ability_def_id";
         col.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
         col.FillWeight   = 150;
         col.HeaderText   = "Ability";
         col.CellTemplate = cell;
         gridAbilities.Columns.Add(col);
     }
     {
         DataGridViewCheckBoxColumn col  = new DataGridViewCheckBoxColumn();
         DataGridViewCheckBoxCell   cell = new DataGridViewCheckBoxCell();
         col.Name         = "is_exempt";
         col.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
         col.FillWeight   = 25;
         col.HeaderText   = "Is Exempt";
         col.CellTemplate = cell;
         gridAbilities.Columns.Add(col);
     }
 }
Ejemplo n.º 5
0
            private void SetupCells()
            {
                _poolCheckBoxCell = new DataGridViewCheckBoxCell {
                    ThreeState = true
                };

                _expansionCell = new DataGridViewImageCell();

                if (Tag is Pool || (Tag is Host && !_hasPool))
                {
                    _poolIconHostCheckCell = new DataGridViewIconCell();
                }
                else
                {
                    _poolIconHostCheckCell = new DataGridViewCheckBoxCell();
                }

                _nameCell    = new DataGridViewNameCell();
                _versionCell = new DataGridViewTextBoxCell();

                Cells.AddRange(new[] { _expansionCell, _poolCheckBoxCell, _poolIconHostCheckCell, _nameCell, _versionCell });

                this.UpdateDetails();
            }
Ejemplo n.º 6
0
        private void btnguardarrol_Click(object sender, EventArgs e)
        {
            SqlConnection unacon = new Conexiones().conectarse();
            List <int>    listaderoles;

            listaderoles = new Rolsql().obtenerRolescoleccion(unacon);
            if (listaderoles.Contains(int.Parse(txtidrol.Text)))
            {
                MessageBox.Show("el numero de rol ya existe");
            }
            else
            {
                SqlCommand cmd = new SqlCommand("gdd_maxi.sp_insertarol", unacon);
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.Add("@id", SqlDbType.Int).Value          = txtidrol.Text;
                cmd.Parameters.Add("@nombre", SqlDbType.NVarChar).Value = txtnombrerol.Text;
                cmd.Parameters.Add("@estado", SqlDbType.Int).Value      = checkBoxhabilitado.Checked;
                cmd.ExecuteNonQuery();
                foreach (DataGridViewRow r in dgvfuncionalidades.Rows)
                {
                    DataGridViewCheckBoxCell chk = r.Cells["habilitada"] as DataGridViewCheckBoxCell;

                    if (Convert.ToBoolean(chk.Value) == true)
                    {
                        SqlCommand cmd2 = new SqlCommand("gdd_maxi.sp_insertarolxfuncionalidad", unacon);

                        cmd2.CommandType = CommandType.StoredProcedure;
                        cmd2.Parameters.Add("@idrol", SqlDbType.Int).Value           = txtidrol.Text;
                        cmd2.Parameters.Add("@idfuncionalidad", SqlDbType.Int).Value = r.Cells["idfuncionalidad"].Value;
                        cmd2.ExecuteNonQuery();
                    }
                }
            }

            unacon.Close();
        }
Ejemplo n.º 7
0
            public DataSourceGridViewRow(DataSourceItem dataSourceItem, bool displayOnGraph)
            {
                this.dsi = dataSourceItem;
                DataGridViewCheckBoxCell displayOnGraphCell = new DataGridViewCheckBoxCell {
                    Value = displayOnGraph
                };

                Cells.Add(displayOnGraphCell);
                DataGridViewTextBoxCell datasourceCell = new DataGridViewTextBoxCell {
                    Value = dsi.ToString()
                };

                Cells.Add(datasourceCell);
                DataGridViewTextBoxCell typeCell = new DataGridViewTextBoxCell {
                    Value = dsi.DataType.ToStringI18N()
                };

                Cells.Add(typeCell);
                DataGridViewTextBoxCell colourCell = new DataGridViewTextBoxCell {
                    Value = dsi.Color
                };

                Cells.Add(colourCell);
            }
Ejemplo n.º 8
0
 private void dgvView_CellMouseUp(object sender, DataGridViewCellMouseEventArgs e)
 {
     if (e.RowIndex == -1)
     {
         return;
     }
     if (e.ColumnIndex == 0)
     {
         int           num   = 1;
         List <string> files = new List <string>();
         foreach (DataGridViewRow row in dgvView.Rows)
         {
             DataGridViewCheckBoxCell cell = row.Cells[0] as DataGridViewCheckBoxCell;
             if (Convert.ToBoolean(cell.EditingCellFormattedValue) == true)
             {
                 files.Add(row.Cells["FileColumn"].Value.ToString());
                 int n = Convert.ToInt32(row.Cells[2].Value);
                 if (n == 1)
                 {
                     row.Cells[4].Value = num.ToString("00000000");
                 }
                 else
                 {
                     row.Cells[4].Value = num.ToString("00000000") + "-" + (num + n - 1).ToString("00000000");
                 }
                 num += n;
             }
             else
             {
                 row.Cells[4].Value = "";
             }
         }
         string info = FilesInfo.GetFilesInfo(files.ToArray());
         lblInfo.Text = info;
     }
 }
Ejemplo n.º 9
0
        private void DgvListado_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.ColumnIndex == DgvListado.Columns["Seleccionar"].Index)
            {
                DataGridViewCheckBoxCell chkEliminar = (DataGridViewCheckBoxCell)
                                                       DgvListado.Rows[e.RowIndex].Cells["seleccionar"];
                chkEliminar.Value = !Convert.ToBoolean(chkEliminar.Value);
                bool valor = Convert.ToBoolean(DgvListado.SelectedCells[10].Value);
                if (valor == true)
                {
                    chkActivar.Value = true;
                }
                else
                {
                    chkActivar.Value = false;
                }
            }

            //foreach (DataGridViewRow columna in DgvListado.Rows)
            //          {
            //              bool valor = Convert.ToBoolean(columna.Cells[4].Value);

            //          }
        }
Ejemplo n.º 10
0
        /// <summary>
        /// get selected row value
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void dgvProcessCardModule_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.ColumnIndex == 0 && e.RowIndex != -1)
            {
                DataGridViewCheckBoxCell chkcel
                    = dgvProcessCardModule[e.ColumnIndex, e.RowIndex] as DataGridViewCheckBoxCell;

                DataGridViewTextBoxCell processProcedureNameCel
                    = dgvProcessCardModule[e.ColumnIndex + 2, e.RowIndex] as DataGridViewTextBoxCell;

                DataGridViewTextBoxCell processProcedureIdCel
                    = dgvProcessCardModule[e.ColumnIndex + 1, e.RowIndex] as DataGridViewTextBoxCell;


                string processProcedureName = processProcedureNameCel.Value.ToString();
                string processProcedureId   = processProcedureIdCel.Value.ToString();

                bool isChecked = Convert.ToBoolean(chkcel.EditedFormattedValue);


                if (isChecked)
                {
                    if (!selecedProcessCardModuleDic.ContainsKey(processProcedureId))
                    {
                        selecedProcessCardModuleDic.Add(processProcedureId, processProcedureName);
                    }
                }
                else
                {
                    if (selecedProcessCardModuleDic.ContainsKey(processProcedureId))
                    {
                        selecedProcessCardModuleDic.Remove(processProcedureId);
                    }
                }
            }
        }
Ejemplo n.º 11
0
        private void IsItemSelected()
        {
            bool FoundItem = false;

            foreach (DataGridViewRow row in dgvMain.Rows)
            {
                DataGridViewCheckBoxCell checkCell = (DataGridViewCheckBoxCell)row.Cells["ObjectSelected"];
                checkCell.TrueValue = true;

                if (Convert.ToBoolean(checkCell.Value) == Convert.ToBoolean(checkCell.TrueValue))
                {
                    FoundItem = true;
                }
            }

            if (FoundItem)
            {
                cmdRestore.Enabled = true;
            }
            else
            {
                cmdRestore.Enabled = false;
            }
        }
Ejemplo n.º 12
0
        private void allShopsDataGrid_CellValueChanged(object sender, DataGridViewCellEventArgs e)
        {
            if (allShopsDataGrid.Columns[e.ColumnIndex].Name == "Check" && e.RowIndex != -1)
            {
                DataGridViewCheckBoxCell checkCell =
                    (DataGridViewCheckBoxCell)allShopsDataGrid.Rows[e.RowIndex].Cells["Check"];

                int shopAddressId = -1;
                if (allShopsDataGrid.Rows[e.RowIndex].Cells["ShopAddressID"].Value != DBNull.Value)
                {
                    shopAddressId = Convert.ToInt32(allShopsDataGrid.Rows[e.RowIndex].Cells["ShopAddressID"].Value);
                }


                bool check = Convert.ToBoolean(checkCell.Value);
                if (check && shopAddressId != -1)
                {
                    shopsManager.AddNewShopAddressOrder(shopAddressId);
                }
                shopsManager.SaveShopAddressOrders();
                shopsManager.SaveShopAddresses();
                shopsManager.UpdatesTables();
            }
        }
Ejemplo n.º 13
0
        private void dataGridViewPedidos_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            try
            {
                if (e.ColumnIndex == (int)Col_Pedidos.RECIBIDO)
                {
                    DataGridViewCheckBoxCell cellSelecion = dataGridViewPedidos.Rows[e.RowIndex].Cells[(int)Col_Pedidos.RECIBIDO] as DataGridViewCheckBoxCell;

                    if (Convert.ToBoolean(cellSelecion.Value))
                    {
                        dataGridViewPedidos.Rows[e.RowIndex].Cells[(int)Col_Pedidos.ESTADO].Value = 2;
                    }

                    if (Convert.ToBoolean(cellSelecion.Value) == false)
                    {
                        dataGridViewPedidos.Rows[e.RowIndex].Cells[(int)Col_Pedidos.ESTADO].Value = 1;
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Ejemplo n.º 14
0
        private void button2_Click(object sender, EventArgs e)
        {
            Camere camera1 = new Camere();

            for (int i = 0; i < dataGridView2.Rows.Count; i++)
            {
                DataGridViewCheckBoxCell cell = dataGridView2.Rows[i].Cells[0] as DataGridViewCheckBoxCell;
                if (cell.Value == cell.TrueValue)
                {
                    camera1.setDisponibilitate(1, Convert.ToInt32(dataGridView2.Rows[i].Cells[1].Value));
                    dataGridView2.Rows.RemoveAt(i);
                    //DELETE DIN Facturi
                }
            }
            //preiau din baza de date

            string         query      = "SELECT ID_Camera,Tip_camera,Descriere_Facilitati,Nr_Locuri,Disponibilitate,Pret_camera FROM Camere WHERE Disponibilitate = 1;";
            string         connstring = "Data Source=(localDb)\\Databases;Initial Catalog=BD_Proiect;Integrated Security=True";
            DataTable      dt         = new DataTable();
            SqlDataAdapter adt        = new SqlDataAdapter(query, connstring);

            adt.Fill(dt);
            dataGridView1.DataSource = dt;
        }
        private void dataGridViewConsolidado_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            try
            {
                if (e.ColumnIndex == (int)Col_GridDetalle.INCLUIR && e.RowIndex != -1)
                {
                    dataGridViewConsolidado.CommitEdit(DataGridViewDataErrorContexts.Commit);
                    //como no desea pediro.. SACO EL TILDE
                    DataGridViewCheckBoxCell cellSelecion = dataGridViewConsolidado.Rows[e.RowIndex].Cells[(int)Col_GridDetalle.INCLUIR] as DataGridViewCheckBoxCell;
                    if (Convert.ToBoolean(cellSelecion.Value))
                    {
                        //VERIFICO SI ESTE ARTICULO QUE ESTA PIDIENDO TIENE PENDIENTE DE ENTREGA-....
                        BLL.Procedures.PEDIENTEENTREGAARTICULO _pendiente = new BLL.Procedures.PEDIENTEENTREGAARTICULO();
                        string _codEmp   = Clases.Usuario.EmpresaLogeada.EmpresaIngresada.ToString().Trim();
                        string _articulo = dataGridViewConsolidado.Rows[e.RowIndex].Cells[(int)Col_GridDetalle.ARTICULO].Value.ToString();

                        _pendiente.Items(_codEmp, _articulo);
                        if (_pendiente.Resultset[0].diferencia > 0)
                        {
                            DialogResult _result = MessageBox.Show("Este artículo tiene pendiente de entrega, desea pedir cotización de todos modos?", "Mensaje", MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
                            if (_result == DialogResult.Cancel)
                            {
                                dataGridViewConsolidado.Rows[e.RowIndex].Cells[(int)Col_GridDetalle.INCLUIR].Value = false;
                                //dataGridViewConsolidado.Rows[e.RowIndex].Cells[(int)Col_GridDetalle.INCLUIR].Selected = false;
                                dataGridViewConsolidado.CommitEdit(DataGridViewDataErrorContexts.Commit);
                            }
                        }
                    }
                }
            }

            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Ejemplo n.º 16
0
        private void LoadLgRecordsFromDb()
        {
            suspendCellVelueChangedEvent = true;
            //DataCzasStart,DataCzasKoniec,LiniaSMT,OperatorSMT,NrZlecenia,Model,IloscWykonana,NGIlosc,ScrapIlosc,Kontrola1szt,KoncowkiLED
            DataTable     sqlTable = SqlOperations.GetLgSmtRecordsFromDb(22, smtLine);
            List <string> lotsList = new List <string>();

            foreach (DataRow row in sqlTable.Rows)
            {
                lotsList.Add(row["NrZlecenia"].ToString().Trim());
            }

            Dictionary <string, string[]> lotToRankABQty = SqlOperations.lotToRankABQty(lotsList.ToArray());

            //dataGridView1.SuspendLayout();
            foreach (DataRow row in sqlTable.Rows)
            {
                string model = row["Model"].ToString();
                if (model[2] == '-')
                {
                    if (lotToRankABQty.ContainsKey(row["NrZlecenia"].ToString()))
                    {
                        dataGridViewLg.Rows.Insert(0);

                        string lotNo   = row["NrZlecenia"].ToString().Trim();
                        string stencil = row["StencilQR"].ToString();

                        LedLeftovers ledLeft = CreateLedLeftovers(row["KoncowkiLED"].ToString(), lotNo, lotToRankABQty);

                        DataGridViewCheckBoxCell chbCell = (DataGridViewCheckBoxCell)dataGridViewLg.Rows[0].Cells[0];
                        chbCell.Value = true;

                        dataGridViewLg.Rows[0].Cells[1].Value = lotNo;
                        string connQty = Tools.GetNumberOfConnectors(row["Model"].ToString().Trim());
                        dataGridViewLg.Rows[0].Cells[3].Value = connQty;
                        if (connQty == "4")
                        {
                            dataGridViewLg.Rows[0].Cells[3].Style.ForeColor = Color.White;
                            dataGridViewLg.Rows[0].Cells[3].Style.BackColor = Color.DarkCyan;
                        }
                        dataGridViewLg.Rows[0].Cells[2].Value = row["Model"].ToString().Trim();
                        //dataGridView1.Rows[0].Cells[4].Value = kontrola pierwszej
                        dataGridViewLg.Rows[0].Cells[5].Value  = lotToRankABQty[lotNo][2];
                        dataGridViewLg.Rows[0].Cells[6].Value  = ledLeft.RankA[0].Nc12;
                        dataGridViewLg.Rows[0].Cells[7].Value  = lotToRankABQty[lotNo][0];
                        dataGridViewLg.Rows[0].Cells[8].Value  = lotToRankABQty[lotNo][1];
                        dataGridViewLg.Rows[0].Cells[9].Value  = row["IloscWykonana"].ToString().Trim();
                        dataGridViewLg.Rows[0].Cells[10].Value = row["NGIlosc"].ToString().Trim();
                        dataGridViewLg.Rows[0].Cells[11].Value = row["ScrapIlosc"].ToString().Trim();
                        dataGridViewLg.Rows[0].Cells[12].Tag   = ledLeft;
                        dataGridViewLg.Rows[0].Cells[12].Value = "OK";

                        dataGridViewLg.Rows[0].Cells[13].Value = DateTime.Parse(row["DataCzasStart"].ToString().Trim());
                        dataGridViewLg.Rows[0].Cells[14].Value = DateTime.Parse(row["DataCzasKoniec"].ToString().Trim());
                        Color cellColor = Tools.GetShiftColor((DateTime)row["DataCzasKoniec"]);
                        dataGridViewLg.Rows[0].Cells[13].Style.BackColor = cellColor;
                        dataGridViewLg.Rows[0].Cells[14].Style.BackColor = cellColor;
                        dataGridViewLg.Rows[0].Cells[15].Style.BackColor = cellColor;

                        dataGridViewLg.Rows[0].Cells[15].Value = row["OperatorSMT"].ToString().Trim();
                        dataGridViewLg.Rows[0].Cells[16].Value = stencil;
                    }
                }
            }
            Tools.AutoSizeColumnsWidth(dataGridViewLg);
            //dataGridView1.ResumeLayout();
            if (dataGridViewLg.Rows.Count > 0)
            {
                dataGridViewLg.CurrentCell = dataGridViewLg.Rows[0].Cells[0];
            }


            suspendCellVelueChangedEvent = false;
        }
Ejemplo n.º 17
0
        private void dataGridView1_CellValueChanged(object sender, DataGridViewCellEventArgs e)
        {
            if (!suspendCellVelueChangedEvent)
            {
                int ngIndex    = dataGridViewLg.Columns.IndexOf(dataGridViewLg.Columns["Ng"]);
                int scrapIndex = dataGridViewLg.Columns.IndexOf(dataGridViewLg.Columns["Scrap"]);
                // Debug.WriteLine("Cell value changed: " + e.RowIndex + " " + e.ColumnIndex);
                //calculate good qty
                if (dataGridViewLg.Rows.Count > 0 & (e.ColumnIndex == ngIndex || e.ColumnIndex == scrapIndex))
                {
                    int rowIndex = e.RowIndex;

                    DataGridViewCell ngCell    = dataGridViewLg.Rows[rowIndex].Cells["Ng"];
                    DataGridViewCell scrapCell = dataGridViewLg.Rows[rowIndex].Cells["Scrap"];

                    double ngValue    = -9999;
                    double scrapValue = -9999;

                    if (ngCell.Value != null)
                    {
                        if (!(double.TryParse(ngCell.Value.ToString(), out ngValue)))
                        {
                            dataGridViewLg.Rows[e.RowIndex].Cells[ngIndex].Value = null;
                            ngValue = -9999;
                        }
                        else
                        {
                            //ng ,0 will be 0
                            dataGridViewLg.Rows[e.RowIndex].Cells[ngIndex].Value = ngValue;
                        }
                    }

                    if (dataGridViewLg.Columns["Scrap"].Visible)
                    {
                        if (scrapCell.Value != null)
                        {
                            if (!(double.TryParse(scrapCell.Value.ToString(), out scrapValue)))
                            {
                                dataGridViewLg.Rows[e.RowIndex].Cells[scrapIndex].Value = null;
                                scrapValue = -9999;
                            }
                        }
                    }
                    else
                    {
                        scrapValue = 0;
                    }

                    if (ngValue > -9999 & scrapValue > -9999 & dataGridViewLg.Rows[e.RowIndex].Cells["ColumnQty"].Value != null)
                    {
                        double orderedQty = double.Parse(dataGridViewLg.Rows[e.RowIndex].Cells["ColumnQty"].Value.ToString());
                        double goodQty    = orderedQty - ngValue - scrapValue;
                        dataGridViewLg.Rows[e.RowIndex].Cells["goodQty"].Value = goodQty;
                    }
                    else
                    {
                        dataGridViewLg.Rows[e.RowIndex].Cells["goodQty"].Value = "";
                    }
                }

                //saving finished LOT
                foreach (DataGridViewRow row in dataGridViewLg.Rows)
                {
                    //Debug.WriteLine("Checking chkBox row:" + row.Index + " " + Convert.ToBoolean(row.Cells["ColumnSaved"].Value));
                    if (!Convert.ToBoolean(row.Cells["ColumnSaved"].Value))
                    {
                        if (IsRowReadyToBeSaved(row))
                        {
                            //Debug.WriteLine("Saving row:" + row.Index);
                            DataGridViewCheckBoxCell ch = (DataGridViewCheckBoxCell)row.Cells["ColumnSaved"];
                            suspendCellVelueChangedEvent = true;
                            lotFinished(ch, row.Index);
                            suspendCellVelueChangedEvent = false;

                            DateTime startDate       = (DateTime)row.Cells["StartDate"].Value;
                            DateTime endDate         = (DateTime)row.Cells["EndDate"].Value;
                            string   firstPieceCheck = "";

                            string stencil = Tools.getCellValue(row.Cells["Stencil"]);

                            LedLeftovers ledLeftovers  = (LedLeftovers)row.Cells["ColumnButtonLed"].Tag;
                            double       totalLedsUsed = 0;
                            string       leftovers     = ledLeftovers.RankA[0].ID + ":" + ledLeftovers.RankA[0].Nc12 + ":" + ledLeftovers.RankA[0].QtyLeft + "|" + ledLeftovers.RankB[0].ID + ":" + ledLeftovers.RankB[0].Nc12 + ":" + ledLeftovers.RankB[0].QtyLeft;
                            for (int i = 0; i < ledLeftovers.RankA.Count; i++)
                            {
                                totalLedsUsed += ledLeftovers.RankA[i].StartQty - ledLeftovers.RankA[i].QtyLeft;
                                totalLedsUsed += ledLeftovers.RankB[i].StartQty - ledLeftovers.RankB[i].QtyLeft;
                                if (i > 0)
                                {
                                    leftovers += "#" + ledLeftovers.RankA[i].ID + ":" + ledLeftovers.RankA[i].Nc12 + ":" + ledLeftovers.RankA[i].QtyLeft + "|" + ledLeftovers.RankB[i].ID + ":" + ledLeftovers.RankB[i].Nc12 + ":" + ledLeftovers.RankB[i].QtyLeft;
                                }
                            }

                            if (row.Cells["ColumnQualityCheck"].Tag != null)
                            {
                                firstPieceCheck = row.Cells["ColumnQualityCheck"].Tag.ToString();
                            }

                            string scrap = "0";
                            if (dataGridViewLg.Columns["Scrap"].Visible)
                            {
                                scrap = row.Cells["Scrap"].Value.ToString();
                            }

                            SqlOperations.SaveRecordToDb(
                                startDate,
                                endDate,
                                smtLine,
                                row.Cells["Operator"].Value.ToString(),
                                row.Cells["ColumnLot"].Value.ToString(),
                                row.Cells["ColumnModel"].Value.ToString(),
                                row.Cells["goodQty"].Value.ToString(),
                                row.Cells["Ng"].Value.ToString(),
                                scrap,
                                firstPieceCheck,
                                leftovers,
                                stencil,
                                "LG",
                                totalLedsUsed);
                            // Debug.WriteLine("Saved");
                            DgvTools.CleanUpLgiDgv(dataGridViewLg);
                        }
                    }
                }
                dataGridViewLg.HorizontalScrollingOffset = 0;
            }
        }
Ejemplo n.º 18
0
        private void Dashboard_Shown(object sender, EventArgs e)
        {
            try
            {
                con.ConnectionString = "Data Source=DESKTOP-69MM1NJ\\SQLEXPRESS;Initial Catalog=NadhamniDB;Integrated Security=True;Pooling=False";
                con.Open();
                if (Home.NewUser == false)
                {
                    SqlCommand cmd = new SqlCommand("select * from Tasks where UserName = '******'", con);

                    SqlDataReader dr = cmd.ExecuteReader();
                    int           i  = 0;
                    while (dr.Read())
                    {
                        ViewTasks.Rows.Add(dr[0], dr[2], dr[1], Convert.ToDateTime(dr[3]).ToShortDateString(), dr[4], dr[5], dr[7], dr[8], dr[6], dr[9]);
                        if (dr["Done"].ToString().Equals("yes"))
                        {
                            DataGridViewCheckBoxCell chkchecking = ViewTasks.Rows[i].Cells["Column10"] as DataGridViewCheckBoxCell;
                            chkchecking.Value = true;
                            i++;
                        }
                    }
                    dr.Close();
                }

                // Dashboard Notes
                if (!Home.Note)
                {
                    SqlCommand cmd = new SqlCommand("select * from Notes where UserName = '******'", con);

                    SqlDataReader dr = cmd.ExecuteReader();
                    while (dr.Read())
                    {
                        ViewNotes.Rows.Add(dr[1], dr[2]);
                    }
                    dr.Close();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                if (con.State == ConnectionState.Open)
                {
                    con.Close();
                }
            }



            try
            {
                con.Open();
                string        selectQuery = "select ProfilePic from Profile  where UserName = '******'";
                SqlCommand    cmd         = new SqlCommand(selectQuery, con);
                SqlDataReader dr          = cmd.ExecuteReader();
                dr.Read();
                if (dr.HasRows)
                {
                    Byte[] img = (Byte[])(dr[0]);
                    if (img == null)
                    {
                        pictureBox7.Image = null;
                    }

                    else
                    {
                        MemoryStream ms = new MemoryStream(img);
                        pictureBox7.Image = Image.FromStream(ms);
                    }
                }
                else
                {
                    MessageBox.Show("error img not found");
                }
            }
            catch (Exception ex)
            { MessageBox.Show(ex.Message); }
            finally
            {
                if (con.State == ConnectionState.Open)
                {
                    con.Close();
                }
            }
            try
            {
                //con.ConnectionString = "Data Source=DESKTOP-AU9FQ00\\SQLEXPRESS;Initial Catalog=NadhamniDB;Integrated Security=True;Pooling=False";
                con.Open();
                SqlCommand    cmd = new SqlCommand("select * from Tasks where DateOfTask='" + (DateTime.Today.AddDays(1)).ToString("yyyy-MM-dd") + "'and UserName='******'", con);
                SqlDataReader dr  = cmd.ExecuteReader();
                if (dr.HasRows)
                {
                    if (!Tasks.tvisited && !Settings.sevisited && !Statistics.svisited)
                    {
                        string planing = "Today you have to: \n";
                        string taskname;
                        string statrttime;
                        string location;
                        while (dr.Read())
                        {
                            taskname   = dr[1].ToString();
                            planing   += taskname + "at ";
                            statrttime = dr[4].ToString();
                            planing   += statrttime + "from ";
                            location   = dr[7].ToString();
                            planing   += location + "\n";
                        }
                        planing += "\n for more informations please check your planing";
                        notifyIcon1.ShowBalloonTip(5000, "Tommorow's planing", planing, ToolTipIcon.Info);
                        notifyIcon1.ShowBalloonTip(5000, "Tommorow's planing", "for more informations,check your tasks", ToolTipIcon.Info);
                    }
                }
                dr.Close();
                //unusual noti
                SqlCommand cmd1    = new SqlCommand("select count(*) from Tasks where DateOfTask='" + (DateTime.Today).ToString("yyyy-MM-dd") + "' and TaskType='" + "unusual" + "' and UserName='******'", con);
                string     nbrdays = Convert.ToString(cmd1.ExecuteScalar());
                if (Convert.ToInt32(cmd1.ExecuteScalar()) > 0)
                {
                    notifyIcon1.ShowBalloonTip(5000, "Don't forget", "you have " + nbrdays + " unusal task(s) for today check your planing for more details", ToolTipIcon.Info);
                }
                //urgent notif
                SqlCommand cmd2 = new SqlCommand("select count(*) from Tasks where DateOfTask='" + (DateTime.Today).ToString("yyyy-MM-dd") + "' and TaskType='" + "urgent" + "' and UserName='******'", con);
                nbrdays = Convert.ToString(cmd2.ExecuteScalar());
                if (Convert.ToInt32(cmd2.ExecuteScalar()) > 0)
                {
                    notifyIcon1.ShowBalloonTip(5000, "Don't forget", "you have " + nbrdays + " urgent task(s) for today check your planing for more details", ToolTipIcon.Info);
                }
            } //end try2
            catch (Exception ex)
            { MessageBox.Show(ex.Message); }
            finally
            {
                if (con.State == ConnectionState.Open)
                {
                    con.Close();
                }
            }

            //label: username shown
            try
            {
                con.Open();
                SqlCommand    cmd = new SqlCommand("select FirstName from Profile where UserName='******'", con);
                SqlDataReader dr  = cmd.ExecuteReader();
                while (dr.Read())
                {
                    txt_firstName.Text = dr[0].ToString();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                if (con.State == ConnectionState.Open)
                {
                    con.Close();
                }
            }
        }
Ejemplo n.º 19
0
        private void datagrid1_cellcontent_click(object sender, DataGridViewCellEventArgs e)
        {
            string headerText = dataGridView1.Columns[e.ColumnIndex].HeaderText;

            //MessageBox.Show(headerText);
            if (headerText == "Select" && e.RowIndex >= 0)
            {
                int     selindex             = dataGridView1.Columns["Select"].Index;
                Boolean bb                   = true; //MessageBox.Show("here" + e.RowIndex + "c" + selindex);
                DataGridViewCheckBoxCell ckb = (DataGridViewCheckBoxCell)dataGridView1.Rows[e.RowIndex].Cells[0];

                if ((bool)ckb.Value)
                {
                    ckb.Value = false;
                }
                else
                {
                    ckb.Value = true;
                }
            }
            if (headerText == "Delete" && e.RowIndex >= 0)
            {
                int    usnindex = dataGridView1.Columns["EVENT_ID"].Index;
                String dusn     = dataGridView1.Rows[e.RowIndex].Cells[usnindex].Value.ToString();
                //MessageBox.Show(dusn);
                if (MessageBox.Show("Do you want to Delete " + dusn + "?", "DELETE", MessageBoxButtons.YesNo) == DialogResult.Yes)
                {
                    int retval = delete_events(dusn);
                    if (retval == 1)
                    {
                        MessageBox.Show("Deleted Successfully");
                        fetch_events();
                    }
                }
            }

            if (headerText == "Update" && e.RowIndex >= 0)
            {
                int eve_idindex   = dataGridView1.Columns["EVENT_ID"].Index;
                int eve_nameindex = dataGridView1.Columns["EVENT_NAME"].Index;
                int typeindex     = dataGridView1.Columns["TYPE"].Index;
                int descindex     = dataGridView1.Columns["DESCRIPTION"].Index;
                int eve_dateindex = dataGridView1.Columns["EVENT_DATE"].Index;
                int eve_timeindex = dataGridView1.Columns["EVENT_TIME"].Index;
                int cateindex     = dataGridView1.Columns["CATEGORY"].Index;

                String uusn = dataGridView1.Rows[e.RowIndex].Cells[eve_idindex].Value.ToString();

                if (MessageBox.Show("Do you want to update " + uusn + "?", "UPDATE", MessageBoxButtons.YesNo) == DialogResult.Yes)
                {
                    textBox1.Text = dataGridView1.Rows[e.RowIndex].Cells[eve_idindex].Value.ToString();
                    textBox2.Text = dataGridView1.Rows[e.RowIndex].Cells[eve_nameindex].Value.ToString();

                    string type = dataGridView1.Rows[e.RowIndex].Cells[typeindex].Value.ToString();
                    comboBox1.SelectedItem = type;
                    string cate = dataGridView1.Rows[e.RowIndex].Cells[cateindex].Value.ToString();
                    comboBox2.SelectedItem = cate;
                    textBox3.Text          = dataGridView1.Rows[e.RowIndex].Cells[descindex].Value.ToString();
                    textBox4.Text          = dataGridView1.Rows[e.RowIndex].Cells[eve_timeindex].Value.ToString();
                    string   dob       = dataGridView1.Rows[e.RowIndex].Cells[eve_dateindex].Value.ToString();
                    string[] dobparms  = dob.Split('-');
                    int      day       = int.Parse(dobparms[0]);
                    int      mon       = int.Parse(dobparms[1]);
                    string[] yearparms = dobparms[2].Split(' ');
                    int      year      = int.Parse(yearparms[0]);
                    dateTimePicker1.Value = new DateTime(year, mon, day);


                    button1.Text     = "Update"; //chenge button Add to Update
                    textBox1.Enabled = false;
                }
            }
        }
Ejemplo n.º 20
0
        public void fetch_events()
        {
            if (!dataGridView1.Columns.Contains("select"))
            {
                dataGridView1.RowHeadersVisible = false;
                DataGridViewCheckBoxColumn dcol = new DataGridViewCheckBoxColumn(); //add select checkbox to all columns
                dcol.HeaderText = "Select";
                dcol.Name       = "select";
                dcol.Width      = 50;
                dcol.Frozen     = false;
                dataGridView1.Columns.Add(dcol);
            }

            string        sql  = "select * from event"; // C#
            OracleCommand ncmd = new OracleCommand(sql, conn);

            using (OracleDataReader reader = ncmd.ExecuteReader())
            {
                DataTable dataTable = new DataTable();
                dataTable.Load(reader);
                dataGridView1.DataSource = dataTable;
            }

            dataGridView1.Columns["EVENT_ID"].Frozen    = true; //makes data grid uneditable
            dataGridView1.Columns["EVENT_NAME"].Frozen  = true;
            dataGridView1.Columns["TYPE"].Frozen        = true;
            dataGridView1.Columns["DESCRIPTION"].Frozen = true;
            dataGridView1.Columns["EVENT_DATE"].Frozen  = true;
            dataGridView1.Columns["EVENT_TIME"].Frozen  = true;
            dataGridView1.Columns["CATEGORY"].Frozen    = true;

            if (!dataGridView1.Columns.Contains("delete"))
            {
                dataGridView1.RowHeadersVisible = false;
                DataGridViewButtonColumn dcol = new DataGridViewButtonColumn(); //add delete button to all columns
                dcol.HeaderText = "Delete";
                dcol.Text       = "delete";
                dcol.Name       = "delete";
                dcol.Width      = 50;

                dcol.UseColumnTextForButtonValue = true;
                dataGridView1.Columns.Add(dcol);
            }

            if (!dataGridView1.Columns.Contains("update"))
            {
                DataGridViewButtonColumn ucol = new DataGridViewButtonColumn(); //add update button to all columns
                ucol.HeaderText = "Update";
                ucol.Text       = "update";
                ucol.Name       = "update";
                ucol.Width      = 50;
                ucol.UseColumnTextForButtonValue = true;
                dataGridView1.Columns.Add(ucol);
            }
            foreach (DataGridViewRow row in dataGridView1.Rows)
            {
                DataGridViewCheckBoxCell chk = (DataGridViewCheckBoxCell)row.Cells[0];
                chk.Value = true;
                chk.Value = false;
            }
        }
Ejemplo n.º 21
0
        public frmRegister()
        {
            InitializeComponent();
            dgvListClass.Columns.Add(new DataGridViewCheckBoxColumn
            {
                Name               = "choose",
                TrueValue          = true,
                FalseValue         = false,
                IndeterminateValue = false,
                Width              = 20
            });
            loadcbTypeuser();
            loadcbgrade();
            loadcbclass();
            loadcbSub();
            LoaddgvListClass();
            btnExit.Click  += btnExit_Click_1;
            btnLogin.Click += BtnLogin_Click;

            cmbTypeUser.SelectedIndexChanged += (s, e) =>
            {
                lblSub.Visible   = false;
                txtClass.Visible = false;
                lblname.Visible  = false;
                lblGrade.Visible = false;
                lblbirth.Visible = false;

                txtName.Visible      = false;
                dtmDOB.Visible       = false;
                cmbSubject.Visible   = false;
                cmbClass.Visible     = false;
                cmbGrade.Visible     = false;
                dgvListClass.Visible = false;

                if (cmbTypeUser.SelectedValue.ToString() == "HS")
                {
                    lblname.Visible  = true;
                    lblGrade.Visible = true;
                    txtClass.Visible = true;
                    lblbirth.Visible = true;

                    cmbGrade.Visible = true;
                    cmbClass.Visible = true;

                    txtName.Visible = true;
                    dtmDOB.Visible  = true;
                }
                else if (cmbTypeUser.SelectedValue.ToString() == "GV")
                {
                    lblSub.Visible   = true;
                    txtClass.Visible = true;
                    lblname.Visible  = true;

                    lblbirth.Visible = true;

                    cmbSubject.Visible = true;

                    dgvListClass.Visible = true;
                    txtName.Visible      = true;
                    dtmDOB.Visible       = true;
                }
                else if (cmbTypeUser.SelectedValue.ToString() == "AD")
                {
                }
            };
            cmbTypeUser.SelectedIndex = 2;
            btnSignUp.Click          += (_, e) =>
            {
                AccessData acc           = new AccessData();
                var        ID            = txtId.Text;
                var        password      = txtPass.Text;
                var        sha1          = new SHA1CryptoServiceProvider();
                var        bytesPw       = ASCIIEncoding.ASCII.GetBytes(password);
                var        bytesPwHashed = sha1.ComputeHash(bytesPw);
                var        sb            = new StringBuilder();
                foreach (byte b in bytesPwHashed)
                {
                    sb.Append(arrHexa[b >> 4]);
                    sb.Append(arrHexa[b & 15]);
                }
                using (var ttn = new QLTTNDataContext())
                {
                    ttn.NguoiDungs.InsertOnSubmit(new NguoiDung
                    {
                        maND    = ID,
                        maLND   = cmbTypeUser.SelectedValue.ToString(),
                        MatKhau = sb.ToString()
                    });

                    if (cmbTypeUser.SelectedValue.ToString() == "HS")
                    {
                        ttn.HocSinhs.InsertOnSubmit(new HocSinh
                        {
                            maHS     = ID,
                            HoTen    = txtName.Text,
                            NgaySinh = dtmDOB.Value,
                            maKhoi   = cmbGrade.SelectedValue.ToString(),
                            maLop    = cmbClass.SelectedValue.ToString()
                        });
                    }
                    else if (cmbTypeUser.SelectedValue.ToString() == "GV")
                    {
                        ttn.GiaoViens.InsertOnSubmit(new GiaoVien
                        {
                            maGV     = ID,
                            HoTen    = txtName.Text,
                            NgaySinh = dtmDOB.Value,
                            maMH     = cmbSubject.SelectedValue.ToString()
                        });

                        //Add teaching
                        foreach (DataGridViewRow r in dgvListClass.Rows)
                        {
                            DataGridViewCheckBoxCell chkchecking = r.Cells[0] as DataGridViewCheckBoxCell;
                            if (Convert.ToBoolean(chkchecking.Value))
                            {
                                ttn.CT_GiangDays.InsertOnSubmit(new CT_GiangDay
                                {
                                    maGV   = ID,
                                    maKhoi = r.Cells[1].Value.ToString(),
                                    maLop  = r.Cells[2].Value.ToString()
                                });
                                ttn.SubmitChanges();
                            }
                        }
                    }


                    ttn.SubmitChanges();
                }

                MessageBox.Show("Đăng Ký Thành Công", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Information); // Nếu đang ký thành công => Sẽ có thông báo Thành Công và đồng thời các TextBox sẽ mất giá trị do [B]ClearTextBox()[/B].
                ClearTextBox();
                this.Close();
            };
        }
Ejemplo n.º 22
0
        private void AddContainerAccess(ContainerAccess containerAccess)
        {
            DataGridViewRow dr = new DataGridViewRow();

            dr.HeaderCell.Value           = containerAccess.ContainerAccessDescription;
            dr.HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleLeft;
            ControlAccess           container = containerAccess.GetContainerAccess();
            DataGridViewTextBoxCell txtCell   = new DataGridViewTextBoxCell();

            dr.Cells.Add(txtCell);
            if (container == null)
            {
                MessageBox.Show("缺少窗体控件权限");
                return;
            }
            dr.Tag = container;
            for (int i = 0; i < 3; i++)
            {
                DataGridViewCheckBoxCell ckbCell = new DataGridViewCheckBoxCell();
                dr.Cells.Add(ckbCell);
            }

            if (container == null)
            {
                dr.Cells[1].Value = true;
                dr.Cells[2].Value = true;
                dr.Cells[3].Value = true;
            }
            else
            {
                dr.Cells[1].Value = (RoleEnums.Operator - container.RoleLevel) >= 0 ? true : false;
                dr.Cells[2].Value = (RoleEnums.Technician - container.RoleLevel) >= 0 ? true : false;
                dr.Cells[3].Value = (RoleEnums.Supervisor - container.RoleLevel) >= 0 ? true : false;
            }

            this.dgvAccess.Rows.Add(dr);

            foreach (ControlAccess item in containerAccess.ControlAccessList)
            {
                if (item.AccessDesrciption == containerAccess.ContainerAccessDescription)
                {
                    continue;
                }
                dr = new DataGridViewRow();
                dr.HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleRight;
                dr.Tag = item;
                DataGridViewTextBoxCell txtCellChild = new DataGridViewTextBoxCell();
                txtCellChild.Style.Alignment = DataGridViewContentAlignment.MiddleLeft;
                dr.Cells.Add(txtCellChild);
                for (int i = 0; i < 3; i++)
                {
                    DataGridViewCheckBoxCell ckbCell = new DataGridViewCheckBoxCell();
                    dr.Cells.Add(ckbCell);
                }
                dr.Cells[0].Value = item.AccessDesrciption;
                dr.Cells[1].Value = (RoleEnums.Operator - item.RoleLevel) >= 0 ? true : false;
                dr.Cells[2].Value = (RoleEnums.Technician - item.RoleLevel) >= 0 ? true : false;
                dr.Cells[3].Value = (RoleEnums.Supervisor - item.RoleLevel) >= 0 ? true : false;
                this.dgvAccess.Rows.Add(dr);
            }
        }
Ejemplo n.º 23
0
        private void Form1_Load(object sender, EventArgs e)
        {
            dbFileName        = "racion.sqlite";
            lbStatusText.Text = "Disconnected";

            #region Connect
            if (!File.Exists(dbFileName))
            {
                MessageBox.Show("Please, create DB and blank table (Push \"Create\" button)");
            }

            try
            {
                m_dbConn = new SQLiteConnection("Data Source=" + dbFileName + ";Version=3;");
                m_dbConn.Open();
                m_sqlCmd.Connection = m_dbConn;

                lbStatusText.Text = "Connected";
            }
            catch (SQLiteException ex)
            {
                lbStatusText.Text = "Disconnected";
                MessageBox.Show("Error: " + ex.Message);
            }
            #endregion Connect

            string sql = "SELECT * FROM ingr_tbl";
            // Создаем объект DataAdapter
            adapter = new SQLiteDataAdapter(sql, m_dbConn);
            // Создаем объект Dataset

            // Заполняем Dataset
            adapter.Fill(ds);
            //Очистка грида
            GridViewer.Rows.Clear();
            GridViewer.Columns.Clear();
            GridViewer.Refresh();
            // Отображаем данные
            GridViewer.DataSource = ds.Tables[0];

            int i = 0;
            GridViewer.AllowUserToOrderColumns = false;

            #region Стиль ячейки
            var cell = new DataGridViewCheckBoxCell()
            {
                TrueValue  = "true",
                FalseValue = "false",
            };
            cell.Style.NullValue = false;
            //this.dataGridView1.Rows[2].Cells[0] = cell;
            #endregion Стиль ячейки

            foreach (DataGridViewColumn col in GridViewer.Columns)
            {
                if (i > 3)
                {
                    //addCheckBoxCell(GridViewer.Rows[0], GridViewer.Rows[0].Cells[i].Value.ToString(),i);
                    //(GridViewer.Rows[0].Cells[i] as DataGridViewCheckBoxCell).Value = true;
                    //(GridViewer[i, 1]. DataGridViewCheckBoxCell).Visible = true;
                }
                col.HeaderCell.Value = ds.Tables[0].Rows[1][i];                       //заголовки
                col.SortMode         = DataGridViewColumnSortMode.NotSortable;        //Сортировка
                col.AutoSizeMode     = DataGridViewAutoSizeColumnMode.DisplayedCells; //Поджать ширину
                if (i == 0)
                {
                    col.Visible = false;
                }
                i++;
            }
        }
Ejemplo n.º 24
0
        public void LoadEditProdList()
        {
            int i;

            //getting first already included products in a transaction
            if (rent != null)
            {
                rent.GetProducts();

                //productsSelected = new int[rent.DTable.Rows.Count];

                DataRow rRow;
                for (i = 0; i < rent.DTable.Rows.Count; i++)
                {
                    rRow = rent.DTable.Rows[i];
                    productsSelected[i] = Int32.Parse(rRow["ID"].ToString());
                }
            }

            if (sales != null)
            {
                sales.GetProducts();

                //productsSelected = new int[sales.DTable.Rows.Count];

                DataRow sRow;
                for (i = 0; i < sales.DTable.Rows.Count; i++)
                {
                    sRow = sales.DTable.Rows[i];
                    productsSelected[i] = Int32.Parse(sRow["ID"].ToString());
                }
            }

            SelectList slist = new SelectList();

            slist.GetAllProducts();
            dtSelProdList.DataSource = slist.DTable;

            //inserting checkbox control
            DataGridViewCheckBoxColumn chkbox = new DataGridViewCheckBoxColumn()
            {
                Name       = "Check",
                FalseValue = 0,
                TrueValue  = 1,
                Visible    = true
            };

            dtSelProdList.Columns.Insert(0, chkbox);


            //initializing checkboxes be checked
            foreach (DataGridViewRow row in dtSelProdList.Rows)
            {
                DataGridViewCheckBoxCell chk = (DataGridViewCheckBoxCell)row.Cells[0];
                if (row.Cells["ID"].Value != null)
                {
                    for (i = 0; i < productsSelected.Length; i++)
                    {
                        if (Int32.Parse(row.Cells[1].Value.ToString()) == productsSelected[i])
                        {
                            chk.Value = chk.TrueValue;
                            break;
                        }
                        else
                        {
                            chk.Value = chk.FalseValue;
                        }
                    }
                }
            }
        }
Ejemplo n.º 25
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            //calculate first total amount
            Product p;
            double  total = 0.00;


            if (rent != null)
            {
                foreach (DataGridViewRow row in dtSelProdList.Rows)
                {
                    if (row.Cells["ID"].Value != null)
                    {
                        DataGridViewCheckBoxCell chk = (DataGridViewCheckBoxCell)row.Cells[0];
                        if (chk.Value == chk.TrueValue)
                        {
                            int prodid = Int32.Parse(row.Cells["ID"].Value.ToString());
                            p           = new Product();
                            p.ProductId = prodid;
                            p.GetProductInfo();
                            total += p.RentPrice;
                        }
                    }
                }
                rent.TotalAmount = total;

                //if EDITting products rented
                if (type == "edit")
                {
                    //updates the total amount of the selected rent
                    rent.UpdateTransaction();

                    //unlinks all products to the rent id
                    TransactionProduct transprod = new TransactionProduct();
                    transprod.TransactionId = rent.TransactionId;
                    transprod.UnLinkRentProducts();
                }
                else //adding NEW rent transaction
                {
                    //saves the transaction of new rental
                    rent.SaveTransaction();

                    //gets the rent id
                    SelectList slist = new SelectList();
                    slist.GetMaxRentalsID();
                    DataRow rRow = slist.DTable.Rows[0];

                    rent.TransactionId = Int32.Parse(rRow["Max"].ToString());
                }

                //then links the products selected
                TransactionProduct tp;
                foreach (DataGridViewRow row in dtSelProdList.Rows)
                {
                    if (row.Cells["ID"].Value != null)
                    {
                        DataGridViewCheckBoxCell chk = (DataGridViewCheckBoxCell)row.Cells[0];
                        if (chk.Value == chk.TrueValue)
                        {
                            tp = new TransactionProduct();
                            tp.TransactionId = rent.TransactionId;

                            tp.ProductId = Int32.Parse(row.Cells["ID"].Value.ToString());

                            tp.LinkRentProduct();
                        }
                    }
                }
                if (type == "add")
                {
                    MessageBox.Show("Transaction Complete!");
                }
                else
                {
                    MessageBox.Show("Transaction Updated!");
                }
                isDone = true;
                this.Close();
            }

            if (sales != null)
            {
                foreach (DataGridViewRow row in dtSelProdList.Rows)
                {
                    if (row.Cells["ID"].Value != null)
                    {
                        DataGridViewCheckBoxCell chk = (DataGridViewCheckBoxCell)row.Cells[0];
                        if (chk.Value == chk.TrueValue)
                        {
                            int prodid = Int32.Parse(row.Cells["ID"].Value.ToString());
                            p           = new Product();
                            p.ProductId = prodid;
                            p.GetProductInfo();
                            total += p.Amount;
                        }
                    }
                }
                sales.TotalAmount = total;

                //if EDITting products sold
                if (type == "edit")
                {
                    //updates the total amount of the selected rent
                    sales.UpdateTransaction();

                    //unlinks all products to the sales id
                    TransactionProduct transprod = new TransactionProduct();
                    transprod.TransactionId = sales.TransactionId;
                    transprod.UnLinkSalesProducts();
                }
                else //adding NEW sales transaction
                {
                    //saves the transaction of new sales
                    sales.SaveTransaction();

                    //gets the rent id
                    SelectList slist = new SelectList();
                    slist.GetMaxSalesID();
                    DataRow rRow = slist.DTable.Rows[0];

                    sales.TransactionId = Int32.Parse(rRow["Max"].ToString());
                }

                //then links the products selected
                TransactionProduct tp;
                foreach (DataGridViewRow row in dtSelProdList.Rows)
                {
                    if (row.Cells["ID"].Value != null)
                    {
                        DataGridViewCheckBoxCell chk = (DataGridViewCheckBoxCell)row.Cells[0];
                        if (chk.Value == chk.TrueValue)
                        {
                            tp = new TransactionProduct();
                            tp.TransactionId = sales.TransactionId;

                            tp.ProductId = Int32.Parse(row.Cells["ID"].Value.ToString());

                            tp.LinkSalesProduct();
                        }
                    }
                }
                if (type == "add")
                {
                    MessageBox.Show("Transaction Complete!");
                }
                else
                {
                    MessageBox.Show("Transaction Updated!");
                }
                isDone = true;
                this.Close();
            }
        }
Ejemplo n.º 26
0
        private void btnSubmitOrder_Click(object sender, EventArgs e)
        {
            if (ReasonableCheck() == false)
            {
                return;
            }

            SqlConnection conn = new SqlConnection(Properties.Settings.Default.connDateString);

            conn.Open();
            SqlCommand cmd = new SqlCommand();

            cmd.Connection = conn;

            DialogResult result            = DialogResult.Cancel;
            int          successOrderCount = 0;

            for (int j = 0; j < deskDataView.Rows.Count; j++)
            {
                DataGridViewCheckBoxCell checkCell = (DataGridViewCheckBoxCell)deskDataView.Rows[j].Cells[2];
                Boolean flag = Convert.ToBoolean(checkCell.Value);
                if (flag == true)
                {
                    List <Dish> dish = new List <Dish>();
                    deskNum  = deskDataView.Rows[j].Cells[0].Value.ToString();
                    orderNum = ControlOrderClass.GetNowOrderNum();
                    for (int k = 0; k < tempDish.Count; k++)
                    {
                        Dish temp = tempDish[k];
                        temp.deskID   = deskNum;
                        temp.orderNum = orderNum;
                        dish.Add(temp);
                    }

                    //orderMsg是订单信息,构造这个订单信息的字符串并打印,用于确认订单信息。
                    StringBuilder orderMsg = new StringBuilder();
                    orderMsg.Append("\t\t请确认订单信息\n\n");
                    orderMsg.Append("订单号:" + orderNum + "\t" + "单位:人民币(元)\n");
                    orderMsg.Append("---------------------------------------------------------------\n");
                    orderMsg.Append("顾客:" + nowOrderDishCustomerName + "\t\t" + "联系方式:" + nowOrderDishCustomerID + "\n");
                    orderMsg.Append("---------------------------------------------------------------\n");
                    cmd.CommandText = string.Format("select Rname from Room where Rid in (select Droomid from Desk where Did = '{0}');", deskNum);
                    string roomName = cmd.ExecuteScalar().ToString();
                    orderMsg.Append("房间:" + roomName + "\t\t" + "餐桌:" + deskNum + "\n");
                    orderMsg.Append("===================================\n");
                    orderMsg.Append("菜的编号\t菜的种类 \t    菜名\t\t菜价\n");

                    //以下是菜的具体信息
                    for (int i = 0; i < tempDish.Count; i++)
                    {
                        cmd.CommandText = string.Format("select Fname, Fprice from Menu where Fid = '{0}';", tempDish[i].foodID);
                        SqlDataReader sdr           = cmd.ExecuteReader();
                        string        tempFoodNname = "";
                        float         tempFoodPrice = 0;
                        if (sdr.Read())
                        {
                            tempFoodNname = sdr["Fname"].ToString();
                            tempFoodPrice = float.Parse(sdr["Fprice"].ToString());
                        }
                        orderMsg.Append("---------------------------------------------------------------\n");
                        orderMsg.Append(string.Format("{0}\t  {1}\t{2,-10}\t{3:f2}\n", tempDish[i].foodID, tempDish[i].foodType, tempFoodNname, tempFoodPrice));
                        sdr.Dispose();
                        sdr.Close();
                    }

                    orderMsg.Append("===================================\n");
                    orderMsg.Append(string.Format("\t\t\t已选{0}道菜,总计{1:f2}元\n", count, orderMoney));

                    DateTime now = DateTime.Now;
                    sqlDate = now.ToString("yyyy-MM-dd");//当天的
                    result  =
                        MessageBox.Show(orderMsg.ToString(), "确认提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Information);
                    if (result == DialogResult.OK)
                    {
                        StringBuilder strSQLinsert = new StringBuilder();
                        strSQLinsert.Append("insert ");
                        strSQLinsert.Append("into CustomerDesk(Ctellphone, Did, Ordernum, Orderdate, Ifcheckout, Ordermoney) ");
                        strSQLinsert.Append(
                            string.Format
                                ("values('{0}','{1}','{2}','{3}','否',{4});", nowOrderDishCustomerID, deskNum, orderNum, sqlDate, orderMoney));
                        cmd.CommandText = strSQLinsert.ToString();
                        cmd.ExecuteNonQuery();

                        cmd.CommandText = string.Format("update Desk set Difuse = '是' where Did = '{0}';", deskNum);
                        cmd.ExecuteNonQuery();

                        StringBuilder strUpdateRoom = new StringBuilder();
                        strUpdateRoom.Append("update Room ");
                        strUpdateRoom.Append("set Rusedesks = Rusedesks + 1 ");
                        strUpdateRoom.Append("where Rid in ");
                        strUpdateRoom.Append(" (select Droomid ");
                        strUpdateRoom.Append("  from Desk ");
                        strUpdateRoom.Append(string.Format("  where Did = '{0}');", deskNum));
                        cmd.CommandText = strUpdateRoom.ToString();
                        cmd.ExecuteNonQuery();

                        for (int i = 0; i < dish.Count; i++)
                        {
                            ControlOrderClass.GetDish(dish[i]);
                            StringBuilder strSQLinsertDeskMenu = new StringBuilder();
                            strSQLinsertDeskMenu.Append("insert ");
                            strSQLinsertDeskMenu.Append("into DeskMenu(Did, Fid, Ordernum, Ifservedish) ");
                            strSQLinsertDeskMenu.Append(
                                string.Format("values('{0}', '{1}', '{2}', '否')"
                                              , dish[i].deskID, dish[i].foodID, dish[i].orderNum));
                            cmd.CommandText = strSQLinsertDeskMenu.ToString();
                            cmd.ExecuteNonQuery();
                        }
                        successOrderCount++;
                    } //END if 点击确认正式下单并更新后台数据库
                }     //END if 桌子为勾选状态
            }         //END for 每张桌子


            MessageBox.Show("成功提交" + successOrderCount + "个订单,请耐心等候!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);

            orderDishListBox.Items.Clear();
            orderDishListBox.Items.Add("菜编号    菜名        菜价");
            count             = 0;
            orderMoney        = 0;
            summaryLabel.Text = string.Format("已选{0}道菜,共计:{1}元", count, orderMoney);
            cmd.Dispose();
            conn.Dispose();
            conn.Close();
            tempDish.Clear();
            this.Close();
        }
Ejemplo n.º 27
0
        public DataGridViewCell GetCell(PropertyInfo property)
        {
            var lockProperInfo = property as LockedByPropertyInfo;

            if (lockProperInfo != null)
            {
                var cell = new DataGridViewImageCell();

                if (lockProperInfo.IsLocked)
                {
                    cell.Value = Resources.img_locked;
                }
                if (!lockProperInfo.IsLockedByMe)
                {
                    cell.Value = Resources.img_locked_else;
                }
                if (!lockProperInfo.IsLocked)
                {
                    cell.Value = null;
                }

                return(cell);
            }

            if (property.DataType == PropertyDataType.Boolean)
            {
                var cell = new DataGridViewCheckBoxCell();
                cell.Value = property.PropertyValue == "1";
                return(cell);
            }

            if (property.DataType == PropertyDataType.Color)
            {
                var cell  = new DataGridViewTextBoxCell();
                var color = string.IsNullOrEmpty(property.PropertyValue) ? Color.White : System.Drawing.ColorTranslator.FromHtml(property.PropertyValue);
                cell.Style.BackColor = color;
                return(cell);
            }

            if (property.DataType == PropertyDataType.ColorList)
            {
                var colors = (property as ColorListPropertyInfo).ColorSource;
                var cell   = new DataGridViewTextBoxCell();

                string value = property.PropertyValue ?? string.Empty;
                string label;

                if (!colors.TryGetValue(value, out label))
                {
                    label = value;
                }

                var color = string.IsNullOrEmpty(value) ? Color.White : ColorTranslator.FromHtml(value);

                cell.Value           = label;
                cell.Style.BackColor = color;
                return(cell);
            }

            if (property.DataType == PropertyDataType.Date)
            {
                var cell = new DataGridViewCalendarCell();

                DateTime dt;
                if (DateTime.TryParse(property.PropertyValue, out dt))
                {
                    cell.Value = dt;
                }
                else
                {
                    cell.Value = property.PropertyValue;
                }

                return(cell);
            }

            if (property.DataType == PropertyDataType.Item)
            {
                var cell = new DataGridViewTextBoxCell();
                cell.Value = property.Label;

                return(cell);
            }

            var defaultCell = new DataGridViewTextBoxCell();

            defaultCell.Value = property.PropertyValue;

            return(defaultCell);
        }
Ejemplo n.º 28
0
 private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
 {
     if (dataGridView1.Columns[e.ColumnIndex].Name == "计算" && e.RowIndex >= 0)
     {
         //获取DataGridView中CheckBox的Cell
         DataGridViewCheckBoxCell dgvCheck = (DataGridViewCheckBoxCell)(dataGridView1.Rows[this.dataGridView1.CurrentCell.RowIndex].Cells["计算"]);
         double score  = 0;
         double credit = 0;
         double point  = 0;
         //根据单击时,Cell的值进行处理。EditedFormattedValue和Value均可以
         //若单击时,CheckBox没有被勾上
         if (Convert.ToBoolean(dgvCheck.EditedFormattedValue) == false)
         {
             dgvCheck.Value = true;
             String numeber1 = dataGridView1.CurrentRow.Cells["score"].Value.ToString();
             String numeber2 = dataGridView1.CurrentRow.Cells["credits"].Value.ToString();
             score = double.Parse(numeber1);
             if (score > 89)
             {
                 point = 4.0;
             }
             else if (score > 84)
             {
                 point = 3.7;
             }
             else if (score > 81)
             {
                 point = 3.3;
             }
             else if (score > 77)
             {
                 point = 3.0;
             }
             else if (score > 74)
             {
                 point = 2.7;
             }
             else if (score > 71)
             {
                 point = 2.3;
             }
             else if (score > 67)
             {
                 point = 2.0;
             }
             else if (score > 63)
             {
                 point = 1.5;
             }
             else if (score > 59)
             {
                 point = 1.0;
             }
             else
             {
                 point = 0;
             }
             credit       = double.Parse(numeber2);
             creditscore += score * credit;
             creditpoint += point * credit;
             countcredit += credit;
         }
         //若单击时,CheckBox已经被勾上
         else
         {
             dgvCheck.Value = false;
             String numeber1 = dataGridView1.CurrentRow.Cells["成绩"].Value.ToString();
             String numeber2 = dataGridView1.CurrentRow.Cells["学分"].Value.ToString();
             score = double.Parse(numeber1);
             if (score > 89)
             {
                 point = 4.0;
             }
             else if (score > 84)
             {
                 point = 3.7;
             }
             else if (score > 81)
             {
                 point = 3.3;
             }
             else if (score > 77)
             {
                 point = 3.0;
             }
             else if (score > 74)
             {
                 point = 2.7;
             }
             else if (score > 71)
             {
                 point = 2.3;
             }
             else if (score > 67)
             {
                 point = 2.0;
             }
             else if (score > 63)
             {
                 point = 1.5;
             }
             else if (score > 59)
             {
                 point = 1.0;
             }
             else
             {
                 point = 0;
             }
             credit       = double.Parse(numeber2);
             creditscore -= score * credit;
             creditpoint -= point * credit;
             countcredit -= credit;
         }
     }
 }
        private void toolStripButtonSave_Click(object sender, EventArgs e)
        {
            try
            {
                Entities.Tables.COMORDENCOMPRA            _OCCabecera = new Entities.Tables.COMORDENCOMPRA();
                BLL.Tables.COMORDENCOMPRA                 _OCCab      = new BLL.Tables.COMORDENCOMPRA();
                Entities.Tables.COMORDENCOMPRAITEM        _OCItem     = new Entities.Tables.COMORDENCOMPRAITEM();
                List <Entities.Tables.COMORDENCOMPRAITEM> _ItemsCab   = new List <Entities.Tables.COMORDENCOMPRAITEM>();

                Boolean _selecciono = false;

                if (this.dataGridViewDetalleReqCotizados.Rows.Count > 0)
                {
                    //cabecera
                    _OCCabecera.FECHA         = Convert.ToDateTime(DateTime.Now.ToShortDateString());                                                                                         //FECHA
                    _OCCabecera.PROVEED_ID    = dataGridViewProveedorCotizado.Rows[dataGridViewProveedorCotizado.CurrentRow.Index].Cells[(int)Col_Proveedores.PROVEEDOR_ID].Value.ToString(); // PROVEEDOR
                    _OCCabecera.ESTADO_ID     = 1;                                                                                                                                            //Ojo ver que valor se envia despues  //ESTADO
                    _OCCabecera.TIPOOC_ID     = 3;                                                                                                                                            //OJO COLOCAR EL VALOR REAL DE ORDEN DE COMPRA SEGUN REQUERIMIENTO
                    _OCCabecera.MODIFICACOSTO = 0;                                                                                                                                            //MODIFICA COSTO
                    string _codEmp = this.comboBoxEmpresa.SelectedValue.ToString();
                    _OCCabecera.CODEMP           = _codEmp;
                    _OCCabecera.CONDICIONPAGO_ID = "0";                // CONDICIOND DE PAGO
                    _OCCabecera.OBS     = this.textBoxObs.Text.Trim(); //OBS
                    _OCCabecera.USUARIO = Clases.Usuario.UsuarioLogeado.usuario_Logeado;
                    int _nroCotizacion = Convert.ToInt32(dataGridViewProveedorCotizado.Rows[dataGridViewProveedorCotizado.CurrentRow.Index].Cells[(int)Col_Proveedores.NROCOTIZACION].Value.ToString());

                    for (int i = 0; i < this.dataGridViewDetalleReqCotizados.Rows.Count; i++)
                    {
                        _OCItem = new Entities.Tables.COMORDENCOMPRAITEM();

                        //RECUPERO LOS ITEMS DE ESTA COTIZACION
                        DataGridViewCheckBoxCell cellSelecion = dataGridViewDetalleReqCotizados.Rows[i].Cells[(int)Col_items.INCLUIR] as DataGridViewCheckBoxCell;

                        if (Convert.ToBoolean(cellSelecion.Value))
                        {
                            //VOY GUARDANSDO LOS ITEMS DE LA ORDEN DE COMPRA
                            _selecciono = true;

                            _OCItem.ARTICULO_ID         = dataGridViewDetalleReqCotizados.Rows[i].Cells[(int)Col_items.ARTICULO_ID].Value.ToString();
                            _OCItem.UNIMED              = dataGridViewDetalleReqCotizados.Rows[i].Cells[(int)Col_items.UNIMED].Value.ToString();
                            _OCItem.PRECIO              = Convert.ToDecimal(dataGridViewDetalleReqCotizados.Rows[i].Cells[(int)Col_items.PRECIO].Value.ToString(), culture);
                            _OCItem.CANTIDAD            = Convert.ToDecimal(dataGridViewDetalleReqCotizados.Rows[i].Cells[(int)Col_items.CANTIDAD].Value.ToString(), culture);
                            _OCItem.FECHAENTREGA        = Convert.ToDateTime(this.dateTimePickerFechaEntrega.Value.ToShortDateString());
                            _OCItem.NIVELAUT_ID         = 1; //ojo ver como se envia despues
                            _OCItem.CODEMPREQUERIMIENTO = _codEmp;


                            //VOY AGREGANDO A LA COLECCION
                            _ItemsCab.Add(_OCItem);
                        }
                    }

                    if (!_selecciono)
                    {
                        MessageBox.Show("Para generar una Orden de Compra, debe seleccionar al menos un artículo", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }

                    //LLAMO A LA FUNCION QUE GUARDA CABECERA E ITEMS
                    int _NroOC;
                    _NroOC = _OCCab.GeneraOrdenDeCompraSegunCotizacion(_OCCabecera, _ItemsCab, _nroCotizacion);
                    if (_NroOC > 0)
                    {
                        MessageBox.Show("Se generó la orden de compra Nro:" + " " + _NroOC, "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        dataGridViewDetalleReqCotizados.Rows.Clear();
                        this.dateTimePickerFechaEntrega.Value = Convert.ToDateTime(DateTime.Now.ToShortDateString());
                        string _empresa = this.comboBoxEmpresa.SelectedValue.ToString();
                        TraeProveedoresCotizados(_empresa);
                    }
                    else
                    {
                        MessageBox.Show("Error al grabar Orden de Compra", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        internal bool HasDifferences() // find out whether there are differences, if not the dialog does not need to be shown
        {                              // at the same time prepare dialog (for the case that there are differences)
            // remove all 'questionable systems' (systems for which exchange-rate differs) from ratesGlobal
            // and put them into the data-grid (for further treatment by the user)
            // also add exchange-rates from ratesCountry which do not (yet) exist in ratesGlobal to the data-grid
            foreach (ExchangeRate rateCountry in ratesCountry)
            {
                foreach (string system in rateCountry.ValidForToList())
                {
                    ExchangeRate matchingGlobal = null;
                    foreach (ExchangeRate rateGlobal in ratesGlobal)
                    {
                        if (rateCountry.Country.ToLower() != rateGlobal.Country.ToLower())
                        {
                            continue;
                        }
                        if (!rateGlobal.ValidForToList().Contains(system))
                        {
                            continue;
                        }
                        matchingGlobal = rateGlobal; break;
                    }
                    if (matchingGlobal != null && matchingGlobal.DefaultRate() == rateCountry.DefaultRate())
                    {
                        continue;               // exchange-rate exists and is equal
                    }
                    if (matchingGlobal == null) // exchange-rate does not (yet) exist in global table
                    {
                        if (rateCountry.DefaultRate() == 1)
                        {
                            continue;                                 // euro-country
                        }
                        int iRow = dgvDiff.Rows.Add(rateCountry.Country, system, rateCountry.DefaultRate(), "n/a",
                                                    true, false, ExchangeRate.JUNE30, "Rate does not (yet) exist in global table.");
                        DataGridViewCheckBoxCell check = dgvDiff.Rows[iRow].Cells[colTakeGlobal.Index] as DataGridViewCheckBoxCell;
                        check.ReadOnly = true; check.Style.BackColor = Color.LightGray;
                    }
                    else // exchange-rate exists, but is different
                    {
                        string hint = string.Empty;
                        if (matchingGlobal.June30 == rateCountry.DefaultRate())
                        {
                            hint = ExchangeRate.JUNE30;
                        }
                        else if (matchingGlobal.YearAverage == rateCountry.DefaultRate())
                        {
                            hint = ExchangeRate.YEARAVERAGE;
                        }
                        else if (matchingGlobal.FirstSemester == rateCountry.DefaultRate())
                        {
                            hint = ExchangeRate.FIRSTSEMESTER;
                        }
                        else if (matchingGlobal.SecondSemester == rateCountry.DefaultRate())
                        {
                            hint = ExchangeRate.SECONDSEMESTER;
                        }
                        if (hint != string.Empty)
                        {
                            hint = string.Format("Country exchange rate matches with global table '{0}': consider changing 'Rate Type'.", hint);
                        }

                        int iRow = dgvDiff.Rows.Add(matchingGlobal.Country, system, rateCountry.DefaultRate(), matchingGlobal.DefaultRate(),
                                                    false, true, matchingGlobal.Default, hint);
                        dgvDiff.Rows[iRow].Tag = matchingGlobal;
                        matchingGlobal.RemoveFromValidFor(system); // remove the system (to add on OK in the way user choses)
                    }
                }
            }
            return(dgvDiff.Rows.Count > 0);
        }