Пример #1
0
        private void buttonEdit_Click(object sender, EventArgs e)
        {
            //得意先と製品が未選択ならなにもしない
            if (comboBoxTokuisaki.SelectedIndex == -1)
            {
                return;
            }
            if (comboBoxSeihin.SelectedIndex == -1)
            {
                return;
            }

            int rowNo = dataGridViewBuhin.CurrentCellAddress.Y;


            FormBuhinMst2 frmBuhin2 = new FormBuhinMst2();

            //FormBuhinMst2のコンボボックス用のデータの準備
            frmBuhin2.材種TableAdapter.Fill(frmBuhin2.dataSetZaisyu.材種);

            //得意先
            frmBuhin2.labelTokuisakiCode.Text = (string)comboBoxTokuisaki.SelectedItem;
            //製品コード
            string scd;

            scd = comboBoxSeihin.SelectedItem.ToString();
            string SeihinCodeStr = Program.Left(scd, 13).Trim();

            frmBuhin2.labelSeihinCode.Text = SeihinCodeStr;
            //製品名
            frmBuhin2.labelSeihinMei.Text = Program.Mid((string)comboBoxSeihin.SelectedItem, 17);
            //行番号
            frmBuhin2.labelNo.Text = (rowNo + 1).ToString();
            //管理番号
            string editNo = string.Format("{0}-{1}", SeihinCodeStr, (string)ds.Tables["部品マスタ"].Rows[rowNo]["部品コード"]);

            frmBuhin2.toolSSLabelKanriCode.Text = editNo;
            //部品コード
            frmBuhin2.textBoxBuhinCode.Text = (string)ds.Tables["部品マスタ"].Rows[rowNo]["部品コード"];
            //使用対象
            frmBuhin2.textBoxSiyoTaisyo.Text = (string)ds.Tables["部品マスタ"].Rows[rowNo]["使用対象"];
            //材種
            frmBuhin2.comboBoxZaisyu.SelectedValue = ds.Tables["部品マスタ"].Rows[rowNo]["材種"];
            //厚さ
            frmBuhin2.textBoxThickness.Text = (string)ds.Tables["部品マスタ"].Rows[rowNo]["厚さ"].ToString();
            // 巾
            frmBuhin2.textBoxWidth.Text = (string)ds.Tables["部品マスタ"].Rows[rowNo]["巾"].ToString();
            // 長さ
            frmBuhin2.textBoxLength.Text = (string)ds.Tables["部品マスタ"].Rows[rowNo]["長さ"].ToString();
            // 数量
            decimal sr;

            sr = (decimal)ds.Tables["部品マスタ"].Rows[rowNo]["数量"];
            frmBuhin2.textBoxSuryo.Text = sr.ToString("#0.#");
            //frmBuhin2.textBoxSuryo.Text = (string)ds.Tables["部品マスタ"].Rows[rowNo]["数量"].ToString();
            // 摘要
            frmBuhin2.textBoxTekiyo.Text = (string)ds.Tables["部品マスタ"].Rows[rowNo]["摘要"];
            // 大井野FL
            frmBuhin2.checkBoxOoino.Checked = (bool)ds.Tables["部品マスタ"].Rows[rowNo]["大井野FL"];
            // NCFL
            frmBuhin2.checkBoxNC.Checked = (bool)ds.Tables["部品マスタ"].Rows[rowNo]["NCFL"];
            // 共通FL
            frmBuhin2.checkBoxKyotu.Checked = (bool)ds.Tables["部品マスタ"].Rows[rowNo]["共通FL"];
            // 在庫FL
            frmBuhin2.checkBoxZaiko.Checked = (bool)ds.Tables["部品マスタ"].Rows[rowNo]["在庫FL"];
            // 別納FL
            frmBuhin2.checkBoxBetuno.Checked = (bool)ds.Tables["部品マスタ"].Rows[rowNo]["別納FL"];
            //シリーズ
            frmBuhin2.toolSSLabelSeries.Text = this.toolSSLabelSeries.Text;

            if (frmBuhin2.ShowDialog() == DialogResult.OK)
            {
                //部品コード
                ds.Tables["部品マスタ"].Rows[rowNo]["部品コード"] = frmBuhin2.textBoxBuhinCode.Text.Trim();
                //使用対象
                ds.Tables["部品マスタ"].Rows[rowNo]["使用対象"] = frmBuhin2.textBoxSiyoTaisyo.Text.Trim();
                //材種
                ds.Tables["部品マスタ"].Rows[rowNo]["材種"] = frmBuhin2.comboBoxZaisyu.SelectedValue;
                //厚さ
                double thickness;
                ds.Tables["部品マスタ"].Rows[rowNo]["厚さ"] = (double.TryParse(frmBuhin2.textBoxThickness.Text, out thickness) ? thickness : 0);
                // 巾
                double width;
                ds.Tables["部品マスタ"].Rows[rowNo]["巾"] = (double.TryParse(frmBuhin2.textBoxWidth.Text, out width) ? width : 0);
                // 長さ
                double length;
                ds.Tables["部品マスタ"].Rows[rowNo]["長さ"] = (double.TryParse(frmBuhin2.textBoxLength.Text, out length) ? length : 0);
                // 数量
                decimal suryo;
                ds.Tables["部品マスタ"].Rows[rowNo]["数量"] = (decimal.TryParse(frmBuhin2.textBoxSuryo.Text, out suryo) ? suryo : 0);
                // 摘要
                ds.Tables["部品マスタ"].Rows[rowNo]["摘要"] = frmBuhin2.textBoxTekiyo.Text;
                // 大井野FL
                ds.Tables["部品マスタ"].Rows[rowNo]["大井野FL"] = frmBuhin2.checkBoxOoino.Checked;
                // NCFL
                ds.Tables["部品マスタ"].Rows[rowNo]["NCFL"] = frmBuhin2.checkBoxNC.Checked;
                // 共通FL
                ds.Tables["部品マスタ"].Rows[rowNo]["共通FL"] = frmBuhin2.checkBoxKyotu.Checked;
                // 在庫FL
                ds.Tables["部品マスタ"].Rows[rowNo]["在庫FL"] = frmBuhin2.checkBoxZaiko.Checked;
                // 別納FL
                ds.Tables["部品マスタ"].Rows[rowNo]["別納FL"] = frmBuhin2.checkBoxBetuno.Checked;


                //RecordDisp(SeihinCodeStr);
            }
        }
Пример #2
0
        private void buttonAdd_Click(object sender, EventArgs e)
        {
            //得意先と製品が未選択ならなにもしない
            if (comboBoxTokuisaki.SelectedIndex == -1)
            {
                return;
            }
            if (comboBoxSeihin.SelectedIndex == -1)
            {
                return;
            }

            //新しい行番号を取得
            int rowCnt = 0;
            int rowNo;

            rowCnt = dataGridViewBuhin.BindingContext[dataGridViewBuhin.DataSource, dataGridViewBuhin.DataMember].Count;
            rowNo  = rowCnt - 1;
            rowCnt++;

            FormBuhinMst2 frmBuhin2 = new FormBuhinMst2();

            //FormBuhinMst2のコンボボックス用のデータの準備
            frmBuhin2.材種TableAdapter.Fill(frmBuhin2.dataSetZaisyu.材種);

            //得意先
            frmBuhin2.labelTokuisakiCode.Text = (string)comboBoxTokuisaki.SelectedItem;
            //製品コード
            string scd;

            scd = comboBoxSeihin.SelectedItem.ToString();
            string SeihinCodeStr = Program.Left(scd, 13).Trim();

            frmBuhin2.labelSeihinCode.Text = SeihinCodeStr;
            //製品名
            frmBuhin2.labelSeihinMei.Text = Program.Mid((string)comboBoxSeihin.SelectedItem, 17);
            //行番号
            frmBuhin2.labelNo.Text = rowCnt.ToString();
            //管理番号
            frmBuhin2.toolSSLabelKanriCode.Text = "";
            //シリーズ
            frmBuhin2.toolSSLabelSeries.Text = this.toolSSLabelSeries.Text;

            if (frmBuhin2.ShowDialog() == DialogResult.OK)
            {
                //得意先
                string tcd;
                tcd = comboBoxTokuisaki.SelectedItem.ToString();
                string TokuisakiCodeStr = Program.Left(tcd, 13).Trim();
                ds.Tables["部品マスタ"].Rows[rowNo]["部品コード"] = TokuisakiCodeStr;
                //製品コード
                ds.Tables["部品マスタ"].Rows[rowNo]["部品コード"] = SeihinCodeStr;
                //行番号
                ds.Tables["部品マスタ"].Rows[rowNo]["部品コード"] = rowCnt.ToString();
                //管理番号
                ds.Tables["部品マスタ"].Rows[rowNo]["部品コード"] = frmBuhin2.toolSSLabelKanriCode.Text;
                //シリーズ
                ds.Tables["部品マスタ"].Rows[rowNo]["部品コード"] = this.toolSSLabelSeries.Text;
                //部品コード
                ds.Tables["部品マスタ"].Rows[rowNo]["部品コード"] = frmBuhin2.textBoxBuhinCode.Text.Trim();
                //使用対象
                ds.Tables["部品マスタ"].Rows[rowNo]["使用対象"] = frmBuhin2.textBoxSiyoTaisyo.Text.Trim();
                //材種
                ds.Tables["部品マスタ"].Rows[rowNo]["材種"] = frmBuhin2.comboBoxZaisyu.SelectedValue;
                //厚さ
                double thickness;
                ds.Tables["部品マスタ"].Rows[rowNo]["厚さ"] = (double.TryParse(frmBuhin2.textBoxThickness.Text, out thickness) ? thickness : 0);
                // 巾
                double width;
                ds.Tables["部品マスタ"].Rows[rowNo]["巾"] = (double.TryParse(frmBuhin2.textBoxWidth.Text, out width) ? width : 0);
                // 長さ
                double length;
                ds.Tables["部品マスタ"].Rows[rowNo]["長さ"] = (double.TryParse(frmBuhin2.textBoxLength.Text, out length) ? length : 0);
                // 数量
                decimal suryo;
                ds.Tables["部品マスタ"].Rows[rowNo]["数量"] = (decimal.TryParse(frmBuhin2.textBoxSuryo.Text, out suryo) ? suryo : 0);
                // 摘要
                ds.Tables["部品マスタ"].Rows[rowNo]["摘要"] = frmBuhin2.textBoxTekiyo.Text;
                // 大井野FL
                ds.Tables["部品マスタ"].Rows[rowNo]["大井野FL"] = frmBuhin2.checkBoxOoino.Checked;
                // NCFL
                ds.Tables["部品マスタ"].Rows[rowNo]["NCFL"] = frmBuhin2.checkBoxNC.Checked;
                // 共通FL
                ds.Tables["部品マスタ"].Rows[rowNo]["共通FL"] = frmBuhin2.checkBoxKyotu.Checked;
                // 在庫FL
                ds.Tables["部品マスタ"].Rows[rowNo]["在庫FL"] = frmBuhin2.checkBoxZaiko.Checked;
                // 別納FL
                ds.Tables["部品マスタ"].Rows[rowNo]["別納FL"] = frmBuhin2.checkBoxBetuno.Checked;

                //RecordDisp(SeihinCodeStr);
            }
        }