Пример #1
0
        private void btn_select_Click(object sender, EventArgs e)
        {
            try
            {
                if (gridView1.SelectedRowsCount.Equals(1))
                {
                    DataRow            targetRow    = gridView1.GetDataRow(gridView1.FocusedRowHandle);
                    productInformation selectedInfo = selectedProductInfo(targetRow);
                    this.SendProductInfoEvent(selectedInfo);
                }
                else
                {
                    int[]     indexes = gridView1.GetSelectedRows();
                    int       length  = indexes.Length;
                    DataRow[] rows    = new DataRow[length];

                    for (int i = 0; i < length; i++)
                    {
                        rows[i] = gridView1.GetDataRow(indexes[i]);
                    }

                    productsInformation selectedInfo = selectedProductsInfo(rows);

                    this.SendProductsInfoEvent(selectedInfo);
                }
                this.Close();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.StackTrace);
                MessageBox.Show(ex.StackTrace);
            }
        }
Пример #2
0
        private productInformation selectedProductInfo(DataRow targetRow)
        {
            productInformation selectedInfo = new productInformation();

            selectedInfo.productID        = Convert.ToString(targetRow["jp_id"]);
            selectedInfo.productName      = Convert.ToString(targetRow["jp_name"]);
            selectedInfo.productNum       = Convert.ToString(targetRow["jp_num"]);
            selectedInfo.carName          = Convert.ToString(targetRow["car"]);
            selectedInfo.modelName        = Convert.ToString(targetRow["model"]);
            selectedInfo.mtrlNum          = Convert.ToString(targetRow["mtrl_num"]);
            selectedInfo.cavity           = Convert.ToString(targetRow["cavity"]);
            selectedInfo.cycleTime        = Convert.ToDecimal(targetRow["cycle_t"]);
            selectedInfo.resinID          = Convert.ToString(targetRow["sj_id"]);
            selectedInfo.resinName        = Convert.ToString(targetRow["sj_name"]);
            selectedInfo.standardPaperURL = Convert.ToString(targetRow["jp_stdpaper"]);

            return(selectedInfo);
        }