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

                Control.支給控除    sCon = new Control.支給控除();
                OleDbDataReader dr;

                sqlStr = " where 支給控除.ID = " + int.Parse(dgv[0, dgv.SelectedRows[iX].Index].Value.ToString());
                dr     = sCon.FillBy(sqlStr);

                if (dr.HasRows == false)
                {
                    dr.Close();
                    sCon.Close();
                    return(false);
                }

                while (dr.Read())
                {
                    tempC.ID     = int.Parse(dr["ID"].ToString());
                    tempC.日付     = DateTime.Parse(dr["日付"].ToString());
                    tempC.配布員ID  = int.Parse(dr["配布員ID"].ToString());
                    tempC.配布員名   = dr["氏名"].ToString();
                    tempC.摘要     = dr["摘要"].ToString() + "";
                    tempC.単価     = double.Parse(dr["単価"].ToString(), System.Globalization.NumberStyles.Any);
                    tempC.数量     = int.Parse(dr["数量"].ToString(), System.Globalization.NumberStyles.Any);
                    tempC.金額     = double.Parse(dr["金額"].ToString(), System.Globalization.NumberStyles.Any);
                    tempC.支給控除区分 = int.Parse(dr["支給控除区分"].ToString());
                }

                dr.Close();
                sCon.Close();
                return(true);
            }
示例#2
0
        private void btnUpdate_Click(object sender, EventArgs e)
        {
            try
            {
                if (fDataCheck() == true)
                {
                    Control.支給控除 sCon = new Control.支給控除();

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

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

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

                        break;
                    }

                    sCon.Close();

                    DispClear();

                    GridviewSet.ShowData(dataGridView1);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message.ToString(), "更新処理", MessageBoxButtons.OK, MessageBoxIcon.Stop);
            }
        }
示例#3
0
            public static void ShowData(DataGridView tempDGV)
            {
                int iX;

                try
                {
                    tempDGV.RowCount = 0;

                    //支給控除マスターのデータリーダーを取得する
                    OleDbDataReader dR;
                    Control.支給控除    sCon = new Control.支給控除();
                    dR = sCon.FillBy("order by ID desc");
                    iX = 0;

                    while (dR.Read())
                    {
                        tempDGV.Rows.Add();

                        tempDGV[0, iX].Value = dR["ID"].ToString();
                        tempDGV[1, iX].Value = DateTime.Parse(dR["日付"].ToString());
                        tempDGV[2, iX].Value = dR["配布員ID"].ToString();
                        tempDGV[3, iX].Value = dR["氏名"].ToString();
                        tempDGV[4, iX].Value = dR["摘要"].ToString();
                        tempDGV[5, iX].Value = double.Parse(dR["単価"].ToString()).ToString("#,##0.0");
                        tempDGV[6, iX].Value = int.Parse(dR["数量"].ToString()).ToString("#,##0");
                        tempDGV[7, iX].Value = double.Parse(dR["金額"].ToString()).ToString("#,##0.0");

                        switch (dR["支給控除区分"].ToString())
                        {
                        case "0":
                            tempDGV[8, iX].Value = "支給";
                            break;

                        case "1":
                            tempDGV[8, iX].Value = "控除";
                            break;
                        }

                        tempDGV[9, iX].Value  = DateTime.Parse(dR["登録年月日"].ToString());
                        tempDGV[10, iX].Value = DateTime.Parse(dR["変更年月日"].ToString());

                        iX++;
                    }

                    dR.Close();

                    sCon.Close();
                }
                catch (Exception e)
                {
                    MessageBox.Show(e.Message, "エラー", MessageBoxButtons.OK);
                }
            }
示例#4
0
        private void btnDel_Click(object sender, EventArgs e)
        {
            //削除確認
            if (MessageBox.Show("削除します。よろしいですか?", "削除確認", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
            {
                return;
            }

            //データ削除
            Control.支給控除 sCon = new Control.支給控除();
            if (sCon.DataDelete(cMaster.ID) == true)
            {
                MessageBox.Show("削除されました", MESSAGE_CAPTION, MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            sCon.Close();

            DispClear();

            GridviewSet.ShowData(dataGridView1);
        }