Exemple #1
0
        private void dataGridViewX1_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            try
            {
                if (_BindingSource == null || _BindingSource.Count < 1)
                {
                    return;
                }

                if (dataGridViewX1.Columns[e.ColumnIndex].Name.Equals("colDelete"))
                {
                    DataGridViewButtonXCell cell = dataGridViewX1.CurrentCell as DataGridViewButtonXCell;
                    if (cell != null)
                    {
                        if (e.RowIndex >= 0 && _BindingSource.Count > e.RowIndex)
                        {
                            AirComAntennaType obj = _BindingSource[e.RowIndex] as AirComAntennaType;
                            _BindingSource.Remove(obj);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                JLog.Instance.Error(ex.Message, MethodBase.GetCurrentMethod().Name,
                                    MethodBase.GetCurrentMethod().Module.Name);
            }
        }
Exemple #2
0
        void DataGridViewX1_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            DataGridViewButtonXCell cell = dataGridViewX1.CurrentCell as DataGridViewButtonXCell;

            if (cell != null)
            {
                DataGridViewButtonXColumn bc =
                    dataGridViewX1.Columns[e.ColumnIndex] as DataGridViewButtonXColumn;

                if (bc != null)
                {
                    string s = Convert.ToString(cell.Value);

                    switch (bc.Name)
                    {
                    case "Country":
                        MessageBox.Show("What a great country " + s + " is!", "",
                                        MessageBoxButtons.OK, MessageBoxIcon.Information);
                        break;

                    case "Region":
                        cell.Value = string.IsNullOrEmpty(s) ? "Global" : "";
                        break;
                    }
                }
            }
        }
Exemple #3
0
        /// <summary>
        /// Handles our "Contact" cell button clicks.
        ///
        /// <remarks>
        /// Clicking on a "Contact" cell will result in the addition or removal of the
        /// cell text from our _ContactTypes list.  The _ContactTypes list is then used
        /// in the BeforeContactCellPaint routine to format the cell display.
        /// </remarks>
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void X1Contact_ButtonClick(object sender, EventArgs e)
        {
            DataGridViewButtonXCell cell =
                dataGridViewX1.CurrentCell as DataGridViewButtonXCell;

            if (cell != null)
            {
                string s = Convert.ToString(cell.Value);

                // If the text was already in our list, then remove it.
                // If it wasn't, then add it.

                if (_ContactTypes.Contains(s))
                {
                    _ContactTypes.Remove(s);
                }
                else
                {
                    _ContactTypes.Add(s);
                }

                // Update the entire column so that each column cell
                // will be reformatted according to the new list values.

                dataGridViewX1.InvalidateColumn(cell.ColumnIndex);
            }
        }
Exemple #4
0
        private void dataGridViewX1_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            DataGridViewButtonXCell cell = dataGridViewX1.CurrentCell as DataGridViewButtonXCell;

            if (cell != null)
            {
                DataGridViewButtonXColumn bc = dataGridViewX1.Columns[e.ColumnIndex] as DataGridViewButtonXColumn;

                if (bc != null)
                {
                    switch (bc.Name)
                    {
                    case "Delete":
                        DialogResult dr = MessageBox.Show("آیا از حذف محصول \"" + dataGridViewX1.Rows[e.RowIndex].Cells["Name"].Value + "\" اطمینان دارید؟", "تایید حذف", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                        if (dr == System.Windows.Forms.DialogResult.Yes)
                        {
                            int                 m     = (int)dataGridViewX1.Rows[e.RowIndex].Cells["code"].Value;
                            DBContext           myDb2 = new DBContext();
                            StoreModels.Product p     = myDb2.products.Where(i => i.Code == m).First();
                            try
                            {
                                myDb2.delete(p);
                                refresh();
                            }
                            catch (System.Data.Entity.Validation.DbEntityValidationException dbEx)
                            {
                                String s = "خطا در ذخیره اطلاعات در پایگاه داده\nمشخصات فنی:\n";
                                foreach (var validationErrors in dbEx.EntityValidationErrors)
                                {
                                    foreach (var validationError in validationErrors.ValidationErrors)
                                    {
                                        System.Diagnostics.Trace.TraceInformation("Property: {0} Error: {1}", validationError.PropertyName, validationError.ErrorMessage);
                                        s = s + "\nProperty: " + validationError.PropertyName + " Error: " + validationError.ErrorMessage;
                                    }
                                }
                                MessageBox.Show(s);
                            }
                            catch (Exception ex)
                            {
                                MessageBox.Show("خطایی رخ داد\n" + ex.Message);
                            }
                        }
                        break;
                    }
                }
            } //if cell ! null
        }     //void dataGridViewX1_CellContentClick
Exemple #5
0
        private void grdDatos_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            try
            {
                DataGridViewButtonXCell cell = grdDatos.CurrentCell as DataGridViewButtonXCell;
                if (cell != null)
                {
                    DataGridViewButtonXColumn bc = grdDatos.Columns[e.ColumnIndex] as DataGridViewButtonXColumn;

                    if (bc != null)
                    {
                        switch (e.ColumnIndex)
                        {
                        case 14:
                            FrmOdcA Fodca = new FrmOdcA(Grupo, grdDatos[0, e.RowIndex].Value.ToString());
                            Fodca.Show(this);
                            break;

                        case 17:
                            FrmFD Fd = new FrmFD(Grupo, grdDatos[0, e.RowIndex].Value.ToString(), txtDesde.Value, txtHasta.Value);
                            Fd.Show(this);
                            break;

                        case 19:
                            Ac[grdDatos.CurrentCell.RowIndex].comprar = Ac[grdDatos.CurrentCell.RowIndex].sugerido;
                            Ac[grdDatos.CurrentCell.RowIndex].total   = Ac[grdDatos.CurrentCell.RowIndex].sugerido * Ac[grdDatos.CurrentCell.RowIndex].costo;
                            Total = Ac.Sum(a => a.total);
                            grdDatos.Refresh();
                            break;
                        }
                    }
                }
            }
            catch (Exception ex1)
            {
                MessageBox.Show(ex1.Message, "Profit Expansion", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }