Exemplo n.º 1
0
        private void btnUpdate_Click(object sender, EventArgs e)
        {
            try
            {
                if (fDataCheck() == true)
                {
                    Control.社員 Shain = new Control.社員();

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

                        if (Shain.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)
                        {
                            Shain.Close();
                            return;
                        }

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

                        break;
                    }

                    Shain.Close();

                    DispClear();

                    //データを 'darwinDataSet.社員' テーブルに読み込みます。
                    this.社員TableAdapter.Fill(this.darwinDataSet.社員);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message.ToString(), "更新処理", MessageBoxButtons.OK, MessageBoxIcon.Stop);
            }
        }
Exemplo n.º 2
0
            /// <summary>
            /// データグリッドビューの指定行のデータを取得する
            /// </summary>
            /// <param name="dgv">対象とするデータグリッドビューオブジェクト</param>
            public static Boolean GetData(DataGridView dgv, ref Entity.社員 tempC)
            {
                int    iX = 0;
                string sqlStr;

                Control.社員      Shain = new Control.社員();
                OleDbDataReader dr;

                sqlStr = " where 社員.ID = " + (int)dgv[0, dgv.SelectedRows[iX].Index].Value;
                dr     = Shain.FillBy(sqlStr);

                if (dr.HasRows == true)
                {
                    while (dr.Read() == true)
                    {
                        tempC.ID    = Convert.ToInt32(dr["ID"].ToString());
                        tempC.氏名    = dr["氏名"].ToString() + "";
                        tempC.フリガナ  = dr["フリガナ"].ToString() + "";
                        tempC.所属コード = Int32.Parse(dr["所属コード"].ToString());
                        tempC.役職    = dr["役職"].ToString() + "";
                        tempC.入社年月日 = dr["入社年月日"].ToString();
                        tempC.備考    = dr["備考"].ToString() + "";
                    }
                }
                else
                {
                    dr.Close();
                    Shain.Close();
                    return(false);
                }

                dr.Close();
                Shain.Close();
                return(true);
            }
Exemplo n.º 3
0
        private void btnDel_Click(object sender, EventArgs e)
        {
            //他に所属登録されているときは削除不可とする
            string SqlStr;

            SqlStr  = " where ";
            SqlStr += "(社員.所属コード = " + txtCode.Text.ToString() + ")  ";

            OleDbDataReader dr;

            Control.社員 Shain = new Control.社員();
            dr = Shain.FillBy(SqlStr);

            //該当所属の社員が登録されているときは削除不可とする
            if (dr.HasRows == true)
            {
                MessageBox.Show(txtName1.Text.ToString() + "の社員が登録されています", txtName1.Text.ToString() + "は削除できません", MessageBoxButtons.OK, MessageBoxIcon.Error);
                dr.Close();
                Shain.Close();
                return;
            }

            dr.Close();
            Shain.Close();

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

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

            DispClear();

            //データを 'darwinDataSet.所属' テーブルに読み込みます。
            this.所属TableAdapter.Fill(this.darwinDataSet.所属);
        }
Exemplo n.º 4
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();

            //得意先に担当者登録されているときは削除不可とする
            SqlStr  = " where ";
            SqlStr += "(得意先.担当社員コード = " + txtCode.Text.ToString() + ")  ";

            Control.得意先 tokui = new Control.得意先();

            dr = tokui.FillBy(SqlStr);

            if (dr.HasRows == true)
            {
                MessageBox.Show(txtName.Text.ToString() + "の担当得意先が存在します", txtName.Text.ToString() + "は削除できません", MessageBoxButtons.OK, MessageBoxIcon.Error);
                dr.Close();
                tokui.Close();
                return;
            }

            dr.Close();
            tokui.Close();

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

            //データ削除
            Control.社員 Shain = new Control.社員();
            if (Shain.DataDelete(Convert.ToInt32(txtCode.Text.ToString())) == true)
            {
                MessageBox.Show("削除されました", MESSAGE_CAPTION, MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            Shain.Close();

            DispClear();

            //データを 'darwinDataSet.社員' テーブルに読み込みます。
            this.社員TableAdapter.Fill(this.darwinDataSet.社員);
        }
Exemplo n.º 5
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.社員      Shain = new Control.社員();
                    OleDbDataReader dr;

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

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

                    dr.Close();
                    Shain.Close();
                }

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

                // 所属
                if (comboBox1.SelectedIndex == -1)
                {
                    comboBox1.Focus();
                    throw new Exception("所属を選択してください");
                }

                //社員クラスにデータセット
                cMaster.ID   = Convert.ToInt32(txtCode.Text.ToString());
                cMaster.氏名   = txtName.Text.ToString();
                cMaster.フリガナ = txtFuri.Text.ToString();

                Utility.ComboShozoku cmb1 = new Utility.ComboShozoku();
                cmb1          = (Utility.ComboShozoku)comboBox1.SelectedItem;
                cMaster.所属コード = cmb1.ID;

                cMaster.役職 = txtYaku.Text.ToString();

                if (iDate.Checked == false)
                {
                    cMaster.入社年月日 = "";
                }
                else
                {
                    cMaster.入社年月日 = iDate.Value.ToShortDateString();
                }

                cMaster.備考 = txtMemo.Text.ToString();

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

                return(true);
            }

            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, MESSAGE_CAPTION + "保守", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return(false);
            }
        }