Exemplo n.º 1
0
        /// <summary>
        /// On cell begin edit of dgvMultipleUnit
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void dgvMultipleUnit_CellBeginEdit(object sender, DataGridViewCellCancelEventArgs e)
        {
            try
            {
                DataTable dtbl   = new DataTable();
                UnitSP    spUnit = new UnitSP();
                if (dgvMultipleUnit.CurrentCell.ColumnIndex == dgvMultipleUnit.Columns["dgvcmbmultipleunit"].Index)
                {
                    dtbl = spUnit.UnitViewAllWithoutPerticularId(decUnitIdExcludeToFillCombo);
                    if (dtbl.Rows.Count > 0)
                    {
                        if (dgvMultipleUnit.RowCount > 1)
                        {
                            int inGridRowCount = dgvMultipleUnit.RowCount;
                            for (int inI = 0; inI < inGridRowCount - 1; inI++)
                            {
                                if (inI != e.RowIndex)
                                {
                                    int inTableRowcount = dtbl.Rows.Count;
                                    for (int inJ = 0; inJ < inTableRowcount; inJ++)
                                    {
                                        if (dgvMultipleUnit.Rows[inI].Cells["dgvcmbmultipleunit"].Value != null && dgvMultipleUnit.Rows[inI].Cells["dgvcmbmultipleunit"].Value.ToString() != "")
                                        {
                                            if (dtbl.Rows[inJ]["unitId"].ToString() == dgvMultipleUnit.Rows[inI].Cells["dgvcmbmultipleunit"].Value.ToString())
                                            {
                                                dtbl.Rows.RemoveAt(inJ);
                                                break;
                                            }
                                        }
                                    }
                                }
                            }
                        }
                        DataGridViewComboBoxCell dgvccProductMultipleUnit = (DataGridViewComboBoxCell)dgvMultipleUnit[dgvMultipleUnit.Columns["dgvcmbmultipleunit"].Index, e.RowIndex];
                        DataRow drow = dtbl.NewRow();
                        drow["unitName"] = string.Empty;
                        drow["unitId"]   = 0;
                        dtbl.Rows.InsertAt(drow, 0);
                        dgvccProductMultipleUnit.DataSource = dtbl;

                        dgvccProductMultipleUnit.ValueMember   = "unitId";
                        dgvccProductMultipleUnit.DisplayMember = "unitName";
                    }
                }
            }
            catch (Exception ex)
            {
                formMDI.infoError.ErrorString = "PMU:29" + ex.Message;
            }
        }
Exemplo n.º 2
0
 /// <summary>
 /// Function to fill the unit combobox
 /// </summary>
 /// <param name="decId"></param>
 public void UnitComboFill(decimal decId)
 {
     try
     {
         DataTable dtbl   = new DataTable();
         UnitSP    spUnit = new UnitSP();
         dtbl = spUnit.UnitViewAllWithoutPerticularId(decId);
         dgvcmbmultipleunit.DataSource = dtbl;
         DataRow drow = dtbl.NewRow();
         drow["unitName"] = string.Empty;
         drow["unitId"]   = 0;
         dtbl.Rows.InsertAt(drow, 0);
         dgvcmbmultipleunit.DisplayMember = "unitName";
         dgvcmbmultipleunit.ValueMember   = "unitId";
     }
     catch (Exception ex)
     {
         formMDI.infoError.ErrorString = "PMU:2" + ex.Message;
     }
 }