예제 #1
0
        private void btnUpdate_Click(object sender, EventArgs e)
        {
            try
            {
                if (fDataCheck() == true)
                {
                    Control.事業所 dCon = new Control.事業所();

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

                        if (dCon.DataInsert(cOffice) == true)
                        {
                            MessageBox.Show("新規登録されました", "事業所マスター", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        }
                        else
                        {
                            MessageBox.Show("新規登録に失敗しました", "事業所マスター", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                        }

                        break;

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

                        if (dCon.DataUpdate(cOffice) == true)
                        {
                            MessageBox.Show("更新されました", "事業所マスター", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        }
                        else
                        {
                            MessageBox.Show("更新に失敗しました", "事業所マスター", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                        }

                        break;
                    }

                    dCon.Close();

                    DispClear();

                    //データを 'jFGMSTSQLDataSet.言語' テーブルに読み込みます。
                    this.事業所TableAdapter.Fill(this.darwinDataSet.事業所);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message.ToString(), "更新処理", MessageBoxButtons.OK, MessageBoxIcon.Stop);
            }
        }
예제 #2
0
        private void btnDel_Click(object sender, EventArgs e)
        {
            //他に事業所登録されているときは削除不可とする
            string SqlStr;

            SqlStr  = " where ";
            SqlStr += "(受注.事業所ID = " + txtCode.Text.ToString() + ")  ";

            OleDbDataReader dr;

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

            //該当事業所の受注データが登録されているときは削除不可とする
            if (dr.HasRows == true)
            {
                MessageBox.Show(txtName.Text.ToString() + "の受注データ登録が存在します", txtName.Text.ToString() + "は削除できません", MessageBoxButtons.OK, MessageBoxIcon.Error);
                dr.Close();
                Jyuchu.Close();
                return;
            }

            dr.Close();
            Jyuchu.Close();

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

            //データ削除
            Control.事業所 Office = new Control.事業所();
            if (Office.DataDelete(Convert.ToInt32(txtCode.Text.ToString())) == true)
            {
                MessageBox.Show("削除されました", "事業所マスター", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            Office.Close();

            DispClear();

            //データを 'darwinDataSet.事業所' テーブルに読み込みます。
            this.事業所TableAdapter.Fill(this.darwinDataSet.事業所);
        }
예제 #3
0
            /// <summary>
            /// データグリッドビューの指定行のデータを取得する
            /// </summary>
            /// <param name="dgv">対象とするデータグリッドビューオブジェクト</param>
            public static Boolean GetData(DataGridView dgv, ref Entity.事業所 tempC)
            {
                int    iX = 0;
                string sqlStr;

                Control.事業所     Office = new Control.事業所();
                OleDbDataReader dr;

                sqlStr = " where 事業所.ID = " + (int)dgv[0, dgv.SelectedRows[iX].Index].Value;
                dr     = Office.FillBy(sqlStr);

                if (dr.HasRows == true)
                {
                    while (dr.Read() == true)
                    {
                        tempC.ID    = Convert.ToInt32(dr["ID"].ToString());
                        tempC.称     = dr["名称"].ToString() + "";
                        tempC.郵便番号  = dr["郵便番号"].ToString() + "";
                        tempC.住所1   = dr["住所1"].ToString() + "";
                        tempC.住所2   = dr["住所2"].ToString() + "";
                        tempC.電話番号  = dr["電話番号"].ToString() + "";
                        tempC.FAX番号 = dr["FAX番号"].ToString() + "";
                        tempC.備考    = dr["備考"].ToString() + "";
                    }
                }
                else
                {
                    dr.Close();
                    Office.Close();
                    return(false);
                }

                dr.Close();
                Office.Close();
                return(true);
            }
예제 #4
0
        //登録データチェック
        private Boolean fDataCheck()
        {
            string str;
            double d;

            try
            {
                //登録モードのとき、コードをチェック
                if (fMode.Mode == 0)
                {
                    // 数字か?
                    if (txtCode.Text == null)
                    {
                        this.txtCode.Focus();
                        throw new Exception("コードは数字で入力してください");
                    }

                    str = this.txtCode.Text;

                    if (double.TryParse(str, System.Globalization.NumberStyles.Any, System.Globalization.NumberFormatInfo.InvariantInfo, out d))
                    {
                    }
                    else
                    {
                        this.txtCode.Focus();
                        throw new Exception("コードは数字で入力してください");
                    }

                    // 未入力またはスペースのみは不可
                    if ((this.txtCode.Text).Trim().Length < 1)
                    {
                        this.txtCode.Focus();
                        throw new Exception("コードを入力してください");
                    }

                    //ゼロは不可
                    if (Convert.ToInt32(this.txtCode.Text.ToString()) == 0)
                    {
                        this.txtCode.Focus();
                        throw new Exception("ゼロは登録できません");
                    }

                    //登録済みコードか調べる
                    string          sqlStr;
                    Control.事業所     Office = new Control.事業所();
                    OleDbDataReader dr;

                    sqlStr = " where ID = " + txtCode.Text.ToString();
                    dr     = Office.FillBy(sqlStr);

                    if (dr.HasRows == true)
                    {
                        txtCode.Focus();
                        dr.Close();
                        Office.Close();
                        throw new Exception("既に登録済みのコードです");
                    }

                    dr.Close();
                    Office.Close();
                }

                //名称チェック
                if (txtName.Text.Trim().Length < 1)
                {
                    txtName.Focus();
                    throw new Exception("名称を入力してください");
                }

                //事業所クラスにデータセット
                cOffice.ID    = Convert.ToInt32(txtCode.Text.ToString());
                cOffice.称     = txtName.Text.ToString();
                cOffice.郵便番号  = txtZipCode.Text.ToString();
                cOffice.住所1   = txtAddress1.Text.ToString();
                cOffice.住所2   = txtAddress2.Text.ToString();
                cOffice.電話番号  = txtTel.Text.ToString();
                cOffice.FAX番号 = txtFax.Text.ToString();
                cOffice.備考    = txtMemo.Text.ToString();

                if (fMode.Mode == 0)
                {
                    cOffice.登録年月日 = DateTime.Today;
                }
                cOffice.更年月日 = DateTime.Today;

                return(true);
            }

            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "事業所マスター保守", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return(false);
            }
        }