示例#1
0
            /// <summary>
            /// データグリッドビューの指定行のデータを取得する
            /// </summary>
            /// <param name="dgv">対象とするデータグリッドビューオブジェクト</param>
            public static Boolean GetData(DataGridView dgv, ref Entity.配布形態 tempC)
            {
                int    iX = 0;
                string sqlStr;

                Control.配布形態    isMode = new Control.配布形態();
                OleDbDataReader dr;

                sqlStr = " where 配布形態.ID = " + (int)dgv[0, dgv.SelectedRows[iX].Index].Value;
                dr     = isMode.FillBy(sqlStr);

                if (dr.HasRows == true)
                {
                    while (dr.Read() == true)
                    {
                        tempC.ID      = Convert.ToInt32(dr["ID"].ToString());
                        tempC.称       = dr["名称"].ToString() + "";
                        tempC.一人当たり枚数 = Convert.ToInt32(dr["一人当たり枚数"].ToString());
                        tempC.備考      = dr["備考"].ToString() + "";
                    }
                }
                else
                {
                    dr.Close();
                    isMode.Close();
                    return(false);
                }

                dr.Close();
                isMode.Close();
                return(true);
            }
示例#2
0
        private void btnDel_Click(object sender, EventArgs e)
        {
            //他に登録されているときは削除不可とする
            string SqlStr;

            SqlStr  = " where ";
            SqlStr += "(受注.配布形態 = " + cMaster.ID.ToString() + ")  ";

            OleDbDataReader dr;

            Control.受注 Order = new Control.受注();
            dr = Order.FillBy(SqlStr);

            //該当配布形態の受注データが登録されているときは削除不可とする
            if (dr.HasRows == true)
            {
                MessageBox.Show(txtName1.Text.ToString() + "の受注データが登録されています", txtName1.Text.ToString() + "は削除できません", MessageBoxButtons.OK, MessageBoxIcon.Error);
                dr.Close();
                Order.Close();
                return;
            }

            dr.Close();
            Order.Close();

            //削除確認
            if (MessageBox.Show("削除します。よろしいですか?", "削除確認", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
            {
                return;
            }

            //データ削除
            Control.配布形態 isMode = new Control.配布形態();
            if (isMode.DataDelete(cMaster.ID) == true)
            {
                MessageBox.Show("削除されました", MESSAGE_CAPTION, MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            isMode.Close();

            DispClear();

            //データを 'darwinDataSet.配布形態' テーブルに読み込みます。
            this.配布形態TableAdapter.Fill(this.darwinDataSet.配布形態);

            GridviewSet.Setting(dataGridView1);
        }
示例#3
0
        private void btnUpdate_Click(object sender, EventArgs e)
        {
            try
            {
                if (fDataCheck() == true)
                {
                    Control.配布形態 isMode = new Control.配布形態();

                    switch (fMode.Mode)
                    {
                    case 0:     //新規登録
                        if (MessageBox.Show("新規登録します。よろしいですか?", "登録確認", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
                        {
                            isMode.Close();
                            return;
                        }

                        if (isMode.DataInsert(cMaster) == true)
                        {
                            MessageBox.Show("新規登録されました", MESSAGE_CAPTION, MessageBoxButtons.OK, MessageBoxIcon.Information);
                        }
                        else
                        {
                            MessageBox.Show("新規登録に失敗しました", MESSAGE_CAPTION, MessageBoxButtons.OK, MessageBoxIcon.Stop);
                        }

                        break;

                    case 1:     //更新
                        if (MessageBox.Show("更新します。よろしいですか?", "更新確認", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
                        {
                            isMode.Close();
                            return;
                        }

                        if (isMode.DataUpdate(cMaster) == true)
                        {
                            MessageBox.Show("更新されました", MESSAGE_CAPTION, MessageBoxButtons.OK, MessageBoxIcon.Information);
                        }
                        else
                        {
                            MessageBox.Show("更新に失敗しました", MESSAGE_CAPTION, MessageBoxButtons.OK, MessageBoxIcon.Stop);
                        }

                        break;
                    }

                    isMode.Close();

                    DispClear();

                    //データを 'darwinDataSet.配布形態' テーブルに読み込みます。
                    this.配布形態TableAdapter.Fill(this.darwinDataSet.配布形態);

                    //GridviewSet.Setting(dataGridView1);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message.ToString(), "更新処理", MessageBoxButtons.OK, MessageBoxIcon.Stop);
            }
        }