예제 #1
0
        private void InitLogic()
        {
            #region  增加
            btnAdd.Click += delegate(object sender, EventArgs e)
            {
                DataTable dt    = gc.DataSource as DataTable;
                DataRow   drNew = dt.NewRow();
                drNew["name"]     = cbxName.EditValue.ToStringEx();
                drNew["typetmp"]  = cbxType.EditValue.ToStringEx();
                drNew["datetmp"]  = DateTime.Now.ToStringEx();
                drNew["moneytmp"] = 0;
                drNew["kcczhm"]   = dt.Compute("max(kcczhm)", null).ToDefaultableInt32() + 1;
                dt.Rows.Add(drNew);
            };
            #endregion

            #region 保存
            btnSav.Click += delegate(object sender, EventArgs e)
            {
                if (!SaveCheck())
                {
                    return;
                }
                AccountSave();
                DataReload();
            };
            #endregion

            #region  除
            btnDel.Click += delegate(object sender, EventArgs e)
            {
                gv.DeleteSelectedRows();
            };
            #endregion

            #region 查询
            btnQry.Click += delegate(object sender, EventArgs e)
            {
                DataReload();
            };
            #endregion

            #region 明细类型
            btnType.Click += delegate(object sender, EventArgs e)
            {
                using (FormType form = new FormType())
                {
                    if (form.DialogResult != DialogResult.Cancel)
                    {
                        form.ShowDialog();
                    }
                }

                InitUICombox();
            };
            #endregion

            #region 一键结清
            btnClear.Click += delegate(object sender, EventArgs e)
            {
                DataTable dt = GetData(string.Format("select name,typetmp,moneytmp,datetmp,comment,kcczhm from account  order by datetmp asc "));
                if (dt == null)
                {
                    return;
                }


                using (FormClear form = new FormClear(dt, cbxName.EditValue.ToStringEx()))
                {
                    if (form.DialogResult != DialogResult.Cancel)
                    {
                        form.ShowDialog();
                    }
                }
            };
            #endregion
        }
예제 #2
0
        private void InitLogic()
        {
            #region  增加
            btnAdd.Click += delegate(object sender, EventArgs e)
            {
                DataTable dt = gc.DataSource as DataTable;
                if (dt == null)
                {
                    return;
                }
                DataRow drNew = dt.NewRow();
                drNew["name"]     = cbxName.EditValue.ToStringEx();
                drNew["typetmp"]  = cbxType.EditValue.ToStringEx();
                drNew["datetmp"]  = DateTime.Now.ToStringEx();
                drNew["moneytmp"] = 0;
                drNew["kcczhm"]   = dt.Compute("max(kcczhm)", null).ToDefaultableInt32() + 1;
                dt.Rows.Add(drNew);
            };
            #endregion

            #region 保存
            btnSav.Click += delegate(object sender, EventArgs e)
            {
                if (!SaveCheck())
                {
                    return;
                }
                AccountSave();
                DataReload();
            };
            #endregion

            #region  除
            btnDel.Click += delegate(object sender, EventArgs e)
            {
                gv.DeleteSelectedRows();
            };
            #endregion

            #region 查询
            btnQry.Click += delegate(object sender, EventArgs e)
            {
                DataReload();
            };
            #endregion

            #region 明细类型
            btnType.Click += delegate(object sender, EventArgs e)
            {
                using (FormType form = new FormType())
                {
                    if (form.DialogResult != DialogResult.Cancel)
                    {
                        form.ShowDialog();
                    }
                }

                InitUICombox();
            };
            #endregion

            #region 用户
            btnUser.Click += delegate(object sender, EventArgs e)
            {
                using (FormUser form = new FormUser())
                {
                    if (form.DialogResult != DialogResult.Cancel)
                    {
                        form.ShowDialog();
                    }
                }

                InitUICombox();
            };
            #endregion

            #region 一键结清
            btnClear.Visible = false;
            btnClear.Click  += delegate(object sender, EventArgs e)
            {
                DataTable dt = GetData(string.Format("select name,typetmp,moneytmp,datetmp,comment,kcczhm from account  order by datetmp asc "));
                if (dt == null)
                {
                    return;
                }

                using (FormClear form = new FormClear(dt, cbxName.EditValue.ToStringEx()))
                {
                    if (form.DialogResult != DialogResult.Cancel)
                    {
                        form.ShowDialog();
                    }
                }
            };
            #endregion

            #region 导出
            btnExport.Click += delegate
            {
                using (SaveFileDialog sf = new SaveFileDialog())
                {
                    if (sf.ShowDialog() != DialogResult.OK)
                    {
                        return;
                    }
                    sf.Title            = "导出Csv文件";
                    sf.Filter           = "Csv文件|*.Csv";
                    sf.RestoreDirectory = true;
                    sf.DefaultExt       = ".csv";

                    gv.OptionsView.ShowFooter = false;
                    gc.ExportToCsv(sf.FileName.ToStringEx() + ".csv");
                    gv.OptionsView.ShowFooter = true;
                }
            };
            #endregion

            #region 导入
            btnImport.Click += delegate
            {
                ImportFromCSVFile();
            };
            #endregion
        }