Ejemplo n.º 1
0
        /// <summary>
        /// Work on dgvProductCreation CellEndEdit event
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void dgvProductCreation_CellEndEdit(object sender, DataGridViewCellEventArgs e)
        {

            try
            {
                if (dgvProductCreation.Columns[e.ColumnIndex].Name == "dgvtxtbatch")
                {
                    string strBatch = dgvProductCreation.Rows[e.RowIndex].Cells[e.ColumnIndex].Value == null ? "" : dgvProductCreation.Rows[e.RowIndex].Cells[e.ColumnIndex].Value.ToString();
                    if (strBatch != "")
                    {
                        BatchSP spBatch = new BatchSP();
                        DataTable dtbl = new DataTable();

                        dtbl = spBatch.BatchViewByName(strBatch, decId);
                        if (dtbl.Rows.Count != 0)
                        {
                            //dgvProductCreation.Rows[e.RowIndex].Cells["dgvtxtbatchId"].Value = Convert.ToDecimal(dtbl.Rows[0]["batchId"]);
                            dgvProductCreation.Rows[e.RowIndex].Cells["dgvtxtExpDate"].Value = dtbl.Rows[0]["expiryDate"];
                            dgvProductCreation.Rows[e.RowIndex].Cells["dgvtxManfDate"].Value = dtbl.Rows[0]["manufacturingDate"];
                        }
                    }
                    else
                    {
                        dgvProductCreation.Rows[e.RowIndex].Cells["dgvtxtExpDate"].Value = string.Empty;
                        dgvProductCreation.Rows[e.RowIndex].Cells["dgvtxManfDate"].Value = string.Empty;
                    }
                }
                if (dgvProductCreation.Columns[e.ColumnIndex].Name == "dgvcmbtgodown")
                {
                    RackSP spRack = new RackSP();
                    RackInfo infoRack = new RackInfo();
                    DataTable dtblRack = new DataTable();
                    decimal decGodownId = Convert.ToDecimal(dgvProductCreation.Rows[e.RowIndex].Cells["dgvcmbtgodown"].Value);
                    dtblRack = spRack.RackNamesCorrespondingToGodownId(decGodownId);
                    DataRow drow = dtblRack.NewRow();
                    drow["rackName"] = string.Empty;
                    drow["rackId"] = 0;
                    dtblRack.Rows.InsertAt(drow, 0);
                    DataGridViewComboBoxCell cell = (DataGridViewComboBoxCell)(dgvProductCreation.Rows[e.RowIndex].Cells["dgvcmbrack"]);
                    cell.DataSource = dtblRack;
                    cell.ValueMember = "rackId";
                    cell.DisplayMember = "rackName";
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("PC:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }