Example #1
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            string err = gridview_err();

            if (err == "")
            {
                int           accountid = add_account();
                StringBuilder str       = new StringBuilder();
                Maticsoft.BLL.account_detail acc_d_bll = new BLL.account_detail();
                int i = 0;
                foreach (GridViewRow row in GridView1.Rows)
                {
                    TextBox wuzi = (TextBox)row.FindControl("wuzi");
                    if (wuzi.Text.Trim() != "")
                    {
                        TextBox danwei   = (TextBox)row.FindControl("danwei");
                        TextBox danjia   = (TextBox)row.FindControl("danjia");
                        TextBox shuliang = (TextBox)row.FindControl("shuliang");
                        TextBox beizhu   = (TextBox)row.FindControl("beizhu");
                        Maticsoft.Model.account_detail acc_d_mod = new Model.account_detail();
                        acc_d_mod.wuzi       = wuzi.Text.Trim();
                        acc_d_mod.danwei     = danwei.Text.Trim();
                        acc_d_mod.danjia     = Convert.ToDecimal(danjia.Text.Trim());
                        acc_d_mod.shuliang   = Convert.ToInt16(shuliang.Text.Trim());
                        acc_d_mod.beizhu     = beizhu.Text.Trim();
                        acc_d_mod.account_id = accountid;
                        if (acc_d_bll.Add(acc_d_mod) > 0)
                        {
                            i++;
                        }
                        ;
                    }
                }
                string add_str = "list.aspx";
                Maticsoft.Common.MessageBox.ShowAndRedirect(this, "共录入了" + i + "条明细", add_str);
            }
            else
            {
                MessageBox.Show(this, err);
                return;
            }
        }
        public void btnSave_Click(object sender, EventArgs e)
        {
            string strErr = "";

            if (this.txtname.Text.Trim().Length == 0)
            {
                strErr += "name不能为空!\\n";
            }

            //if(!PageValidate.IsDateTime(txttime.Text))
            //{
            //    strErr+="time格式错误!\\n";
            //}
            //if(!PageValidate.IsNumber(txtpeixunban_id.Text))
            //{
            //    strErr+="peixunban_id格式错误!\\n";
            //}
            //if(this.txtbeizhu.Text.Trim().Length==0)
            //{
            //    strErr+="beizhu不能为空!\\n";
            //}
            //if(this.txtbeizhu2.Text.Trim().Length==0)
            //{
            //    strErr+="beizhu2不能为空!\\n";
            //}

            if (strErr != "")
            {
                MessageBox.Show(this, strErr);
                return;
            }
            int    id   = int.Parse(this.lblid.Text);
            string name = this.txtname.Text;

            string txtleibei = leibie.SelectedValue;
            //string lururen=this.txtlururen.Text;
            //DateTime time=DateTime.Parse(this.txttime.Text);
            //int peixunban_id=int.Parse(this.txtpeixunban_id.Text);
            string beizhu  = this.txtbeizhu.Text;
            string beizhu2 = this.txtbeizhu2.Text;


            Maticsoft.Model.account model = new Maticsoft.Model.account();
            model.id      = id;
            model.name    = name;
            model.leibei  = txtleibei;
            model.lururen = lururen.Text;
            model.time    = DateTime.Parse(lurushijian.Text);
            if (leibie.SelectedValue == "培训班费用")
            {
                model.peixunban_id = Convert.ToInt16(qishu.SelectedValue);
            }
            else
            {
                model.peixunban_id = 0;
            }
            model.beizhu  = beizhu;
            model.beizhu2 = beizhu2;

            Maticsoft.BLL.account bll = new Maticsoft.BLL.account();
            bll.Update(model);

            string err = gridview_err();

            if (err == "")
            {
                StringBuilder str = new StringBuilder();
                Maticsoft.BLL.account_detail acc_d_bll = new BLL.account_detail();
                int i = 0;
                foreach (GridViewRow row in GridView1.Rows)
                {
                    TextBox wuzi = (TextBox)row.FindControl("wuzi");
                    if (wuzi.Text.Trim() != "")
                    {
                        Label   mingxidanhao = (Label)row.FindControl("mingxidanhao");
                        TextBox danwei       = (TextBox)row.FindControl("danwei");
                        TextBox danjia       = (TextBox)row.FindControl("danjia");
                        TextBox shuliang     = (TextBox)row.FindControl("shuliang");
                        TextBox beizhu1      = (TextBox)row.FindControl("beizhu");
                        Maticsoft.Model.account_detail acc_d_mod = new Model.account_detail();

                        acc_d_mod.wuzi       = wuzi.Text.Trim();
                        acc_d_mod.danwei     = danwei.Text.Trim();
                        acc_d_mod.danjia     = Convert.ToDecimal(danjia.Text.Trim());
                        acc_d_mod.shuliang   = Convert.ToInt16(shuliang.Text.Trim());
                        acc_d_mod.beizhu     = beizhu1.Text.Trim();
                        acc_d_mod.account_id = Convert.ToInt16(lblid.Text);
                        if (mingxidanhao.Text == "")
                        {
                            acc_d_bll.Add(acc_d_mod);
                            i++;
                        }
                        else
                        {
                            acc_d_mod.id = Convert.ToInt16(mingxidanhao.Text);
                            if (acc_d_bll.Update(acc_d_mod))
                            {
                                i++;
                            }
                            ;
                        }
                    }
                }
                string add_str = "list.aspx";
                Maticsoft.Common.MessageBox.ShowAndRedirect(this, "共更新了" + i + "条明细", add_str);
            }
            else
            {
                MessageBox.Show(this, err);
                return;
            }
        }