コード例 #1
0
ファイル: Main_ADD.cs プロジェクト: bosl95/Lottery-Book
        private void button_add_Click(object sender, EventArgs e)
        {
            if (textBox_detail.Text == "" || textBox_amount.Text == "" || (checkBox.Checked == false && (CB_bankname.Text == "" || CB_account.Text == "")) || comboBox_type.Text == "" || comboBox_category.Text == "")
            {
                MessageBox.Show("공백란이 존재합니다.");
                return;
            }

            string[] time = dateTimePicker_time.Value.ToString().Split(' ');
            if (time[1] == "오후")
            {
                string[] temp_time = time[2].Split(':');
                temp_time[0] = (Int32.Parse(temp_time[0]) + 12).ToString();
                if (temp_time[0] == "24")
                {
                    temp_time[0] = "12";
                }
                time[2] = temp_time[0] + ":" + temp_time[1] + ":" + temp_time[2];
            }
            else
            {
                string[] temp_time = time[2].Split(':');
                if (temp_time[0] == "12")
                {
                    temp_time[0] = "00";
                }
                time[2] = temp_time[0] + ":" + temp_time[1] + ":" + temp_time[2];
            }
            string sql = "INSERT INTO LOG VALUES ('" + dateTimePicker.Value.ToShortDateString() + " " + time[2] + "','"
                         + textBox_detail.Text + "','"
                         + textBox_amount.Text + "','"
                         + CB_account.Text + "','"
                         + comboBox_type.Text + "','"
                         + comboBox_category.Text + "')";

            MessageBox.Show(dateTimePicker.Value.ToShortDateString() + " " + time[2]);
            Callcmd(sql);


            if (comboBox_type.Text == "수입" || comboBox_type.Text == "저축")
            {
                sql = "UPDATE BANK SET B_sum=B_sum+'" + textBox_amount.Text + "' WHERE B_account='" + CB_account.Text + "';";
                Callcmd(sql);
            }
            else
            {
                sql = "UPDATE BANK SET B_sum=B_sum-'" + textBox_amount.Text + "' WHERE B_account='" + CB_account.Text + "';";
                Callcmd(sql);
            }
            main.Readlog();
            textBox_amount.Text = textBox_detail.Text = "";
        }
コード例 #2
0
ファイル: MAIN_modify.cs プロジェクト: bosl95/Lottery-Book
        private void button_modify_Click(object sender, EventArgs e)
        {
            //item.SubItems[0].Text = DateTime.Parse(dateTimePicker.Text).ToString("yyyy-MM-dd");
            if (textBox_detail.Text == "" || textBox_amount.Text == "" || comboBox_type.Text == "" || comboBox_category.Text == "")
            {
                MessageBox.Show("공백이 존재합니다!");
                return;
            }

            if (checkBox.Checked)    //현금일경우
            {
                CB_bankname.Text = "";
                CB_account.Text  = "";
            }

            string[] time = item.SubItems[0].Text.Split(' ');
            if (time[1] == "오후")
            {
                string[] temp_time = time[2].Split(':');
                temp_time[0] = (Int32.Parse(temp_time[0]) + 12).ToString();
                if (temp_time[0] == "24")
                {
                    temp_time[0] = "12";
                }
                time[2] = temp_time[0] + ":" + temp_time[1] + ":" + temp_time[2];
            }
            else
            {
                string[] temp_time = time[2].Split(':');
                if (temp_time[0] == "12")
                {
                    temp_time[0] = "00";
                }
                time[2] = temp_time[0] + ":" + temp_time[1] + ":" + temp_time[2];
            }

            string sql = "UPDATE LOG SET L_detail='" + textBox_detail.Text + "', L_amount='" + textBox_amount.Text + "', B_account='" + CB_account.Text + "', L_type='" + comboBox_type.Text + "', L_category='" + comboBox_category.Text + "' WHERE L_date='" + time[0] + " " + time[2] + "'";

            main.Callcmd(sql);

            main.Readlog();
            Close();
        }