差旅报销流程开发--表单篇
上次使用智遥工作流弄了一个简单的”请休假流程“,只有一个主表,比较简单;所有的代码都是一键自动生成。只需稍微调整一下样子,即可。领导挺满意。
今天做了一个复杂一点”差旅报销流程“,报销单需要一个主表和一个明细表。其实做法都一样.
1.设计表结构(一个主表+明细表)
2.点击自动生成代码
3.调整一下界面样子
4.根据需要再扩展一下,比如:小计,合计功能
主表的代码和之前的请假单代码结构一样,让我们来看看明细表操作的代码吧:
#region --操作明细表------------------------- //查看 protected void BView_CLFBX_MX_Click(object sender, DirectEventArgs e) { HCmd_CLFBX_MX.Text = "V";//V查看 A新增 E修改 Cmd_CLFBX_MX(); } //新增 protected void BAdd_CLFBX_MX_Click(object sender, DirectEventArgs e) { HCmd_CLFBX_MX.Text = "A";//V查看 A新增 E修改 Cmd_CLFBX_MX(); } //修改 protected void BEdit_CLFBX_MX_Click(object sender, DirectEventArgs e) { HCmd_CLFBX_MX.Text = "E";//V查看 A新增 E修改 Cmd_CLFBX_MX(); } //删除 protected void BDelete_CLFBX_MX_Click(object sender, DirectEventArgs e) { StringBuilder sqlStr = new StringBuilder(); sqlStr.Append("Delete CLFBX_MX where "); sqlStr.Append(" workid = '" + Tworkid.Text.ToString() + "' and id='"+CLFBX_MX_id.Text.Trim()+"'"); sh.Execute(sqlStr.ToString()); BindCLFBX_MX(); UpdateTotalMoney(); } protected void Cmd_CLFBX_MX() { string cmd = HCmd_CLFBX_MX.Text.ToString(); if (cmd == "V") { BSave_CLFBX_MX.Hide(); Window_CLFBX_MX.Title = "查看"; Window_CLFBX_MX.Icon = Icon.PageMagnify; Window_CLFBX_MX.Show(); } else if (cmd == "A") { BSave_CLFBX_MX.Show(); Window_CLFBX_MX.Title = "新增"; Window_CLFBX_MX.Icon = Icon.PageAdd; Window_CLFBX_MX.Show(); } else if (cmd == "E") { BSave_CLFBX_MX.Show(); Window_CLFBX_MX.Title = "修改"; Window_CLFBX_MX.Icon = Icon.PageEdit; ; Window_CLFBX_MX.Show(); } } //保存 protected void BSave_CLFBX_MX_Click(object sender, DirectEventArgs e) { Hidden HCmd = (Hidden)Master.FindControl("HCmd"); string cmdM = HCmd.Text.ToUpper(); string CFnid = GetCurrentFnid(cmdM); if (CLFBX_MX_Check(CFnid) == true) { string v_id = CLFBX_MX_id.Text.ToString(); string v_startdate = CLFBX_MX_startdate.Text.ToString(); string v_enddate = CLFBX_MX_enddate.Text.ToString(); string v_place = CLFBX_MX_place.Text.ToString(); string v_days = CLFBX_MX_days.Text.ToString(); string v_fee_ticket = CLFBX_MX_fee_ticket.Text.ToString(); string v_fee_hotel = CLFBX_MX_fee_hotel.Text.ToString(); string v_fee_traffic = CLFBX_MX_fee_traffic.Text.ToString(); string v_bz1 = CLFBX_MX_bz1.Text.ToString(); string v_zsbz = CLFBX_MX_zsbz.Text.ToString(); string v_fee_other = CLFBX_MX_fee_other.Text.ToString(); string v_workid = Tworkid.Text; string v_creator = u.GetLoginID(); string v_modifier = u.GetLoginID(); string v_ctime = DateTime.Now.ToString(); string v_mtime = DateTime.Now.ToString(); CLFBX_MX_subtotal.Text = (Convert.ToDecimal(v_fee_hotel) + Convert.ToDecimal(v_fee_ticket) + Convert.ToDecimal(v_fee_traffic) + Convert.ToDecimal(v_fee_other) + Convert.ToDecimal(v_bz1) + Convert.ToDecimal(v_zsbz)).ToString(); string v_subtotal = CLFBX_MX_subtotal.Text.ToString(); StringBuilder sqlStr = new StringBuilder(); sqlStr.Clear(); string cmd = HCmd_CLFBX_MX.Text.ToString(); if (cmd == "A") { //判断主键是否重复 //sqlStr.Append("Select count(*) from CLFBX_MX where "); //sqlStr.Append("workid='" + v_workid + "' and id='"+v_id+"'"); //if (sh.Exists(sqlStr.ToString()) == false) //{ sqlStr.Clear(); sqlStr.Append("Insert into CLFBX_MX ("); sqlStr.Append("workid,"); sqlStr.Append("startdate,"); sqlStr.Append("enddate,"); sqlStr.Append("place,"); sqlStr.Append("days,"); sqlStr.Append("fee_ticket,"); sqlStr.Append("fee_hotel,"); sqlStr.Append("fee_traffic,"); sqlStr.Append("bz1,"); sqlStr.Append("zsbz,"); sqlStr.Append("subtotal,"); sqlStr.Append("fee_other,"); sqlStr.Append(" creator,ctime) values( "); sqlStr.Append("'" + v_workid + "',"); sqlStr.Append("'" + v_startdate + "',"); sqlStr.Append("'" + v_enddate + "',"); sqlStr.Append("'" + v_place + "',"); sqlStr.Append("'" + v_days + "',"); sqlStr.Append("'" + v_fee_ticket + "',"); sqlStr.Append("'" + v_fee_hotel + "',"); sqlStr.Append("'" + v_fee_traffic + "',"); sqlStr.Append("'" + v_bz1 + "',"); sqlStr.Append("'" + v_zsbz + "',"); sqlStr.Append("'" + v_subtotal + "',"); sqlStr.Append("'" + v_fee_other + "',"); sqlStr.Append("'" + v_creator + "','" + v_ctime + "')"); sh.Execute(sqlStr.ToString()); Form_CLFBX_MX.Reset(); UpdateTotalMoney(); //} //else //{ // X.Msg.Alert("提示:", "已经存在,不能重复添加!").Show(); //} } else if (cmd == "E") { sqlStr.Clear(); sqlStr.Append("Update CLFBX_MX Set "); sqlStr.Append("startdate='" + v_startdate + "',"); sqlStr.Append("enddate='" + v_enddate + "',"); sqlStr.Append("place='" + v_place + "',"); sqlStr.Append("days='" + v_days + "',"); sqlStr.Append("fee_ticket='" + v_fee_ticket + "',"); sqlStr.Append("fee_hotel='" + v_fee_hotel + "',"); sqlStr.Append("fee_traffic='" + v_fee_traffic + "',"); sqlStr.Append("bz1='" + v_bz1 + "',"); sqlStr.Append("zsbz='" + v_zsbz + "',"); sqlStr.Append("subtotal='" + v_subtotal + "',"); sqlStr.Append("fee_other='" + v_fee_other + "',"); sqlStr.Append("modifier='" + v_modifier + "',mtime='" + v_mtime + "'"); sqlStr.Append(" Where "); sqlStr.Append("workid='" + v_workid + "' and id='"+v_id+"'"); sh.Execute(sqlStr.ToString()); Window_CLFBX_MX.Hide(); UpdateTotalMoney(); } BindCLFBX_MX(); } } // 保存前检查 protected bool CLFBX_MX_Check(string CFnid) { bool pass = true; string msg = ""; switch (CFnid) { case "A": if (CLFBX_MX_startdate.Text.ToString() == "") { msg += "请输入起始日期!<br/>"; } if (CLFBX_MX_enddate.Text.ToString() == "") { msg += "请输入截止日期!<br/>"; } if (CLFBX_MX_days.Text.Trim() == "") { msg += "请输入天数!<br/>"; } break; //case "A01": //根据实际需要填写 //break; } if (msg != "") { pass = false; X.Msg.Alert("提示:", msg).Show(); } return pass; } //绑定数据------------- protected void BindCLFBX_MX() { string sql = "Select * from CLFBX_MX where workid='" + Tworkid.Text.ToString() + "'"; Store_CLFBX_MX.DataSource = sh.Query(sql); Store_CLFBX_MX.DataBind(); } #endregion --操作明细表
注:以上代码都是系统自动生成的。
不知道怎么写了,上图吧
明细表的操作是:点新增,然后弹出一个窗体给你输入(这些都是自动生成的)
审批截图