Exemple #1
0
 //确认修改
 private void btnEnter_Click(object sender, EventArgs e)
 {
     try
     {
         string  deleteId = dataGridView1.SelectedRows[0].Cells["Id"].Value.ToString();
         string  date     = cboYear.Text + '-' + cboMonth.Text + '-' + cboDay.Text;
         string  sql      = string.Format("update Consume set ConsumeDate='{0}',Name='{1}',Type='{2}',Category='{3}',ConsumeMoney='{4}',Descrition='{5}'where Id={6}", date, cboName.Text, cboType.Text, cboCategory.Text, txtMoney.Text.Trim(), txtDescription.Text.Trim(), deleteId);
         DataCmd dc       = new DataCmd();
         dc.DataBaseCommand(sql);
         FreshData();
         #region 清空CBO
         cboNumber.Text      = "";
         cboName.Text        = "";
         cboType.Text        = "";
         cboCategory.Text    = "";
         txtMoney.Text       = "";
         txtDescription.Text = "";
         cboYear.Text        = "";
         cboMonth.Text       = "";
         cboDay.Text         = "";
         #endregion
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
Exemple #2
0
        private void BtnIntoMonthCount_Click(object sender, EventArgs e)
        {
            string  sql = string.Format("insert into MonthCount (Year,Month,PayCount,IncomeCount,Count) values('{0}','{1}','{2}','{3}','{4}')", cboSelectYear.Text.Trim(), cboSelectMonth.Text.Trim(), txtSelectOut.Text.Trim(), txtSelectIn.Text.Trim(), txtSelectSurplus.Text);
            DataCmd dc  = new DataCmd();

            dc.DataBaseCommand(sql);
        }
Exemple #3
0
        //确认增加记录
        private void btnEnter_Click(object sender, EventArgs e)
        {
            string  date = cboYear.Text + '-' + cboMonth.Text + '-' + cboDay.Text;
            string  sql  = string.Format("insert into Consume values('{0}','{1}','{2}','{3}','{4}','{5}')", date, cboName.Text.Trim(), cboType.Text.Trim(), cboCategory.Text.Trim(), txtMoney.Text.Trim(), txtDescription.Text.Trim());
            DataCmd dc   = new DataCmd();

            dc.DataBaseCommand(sql);
        }
Exemple #4
0
        //删除记录
        private void btnDelete_Click(object sender, EventArgs e)
        {
            if (this.dataGridView1.SelectedRows.Count <= 0)
            {
                return;
            }
            string deleteId = dataGridView1.SelectedRows[0].Cells["Id"].Value.ToString();

            if (MessageBox.Show("确认要删除吗?", "请确认", MessageBoxButtons.OKCancel) == DialogResult.OK)
            {
                string  sql = string.Format("delete from Consume where Id={0}", deleteId);
                DataCmd d   = new DataCmd();
                d.DataBaseCommand(sql);
            }
            FreshData();
        }