private void btnSubmit_Click(object sender, RoutedEventArgs e) { try { decimal zhekou = -1; decimal.TryParse(txtZHKOU.Text, out zhekou); this.txtZHKOU.Text = zhekou.ToString(); //固定/可分配提成比例 decimal ratio1 = 60; decimal ratio2 = 40; PTS_OBJECT_TYPE_SRC src = PTS_OBJECT_TYPE_SRCDAO.FindFirst(new EqExpression("STATUS", 1)); if (src != null) { ratio1 = src.RATIO1; ratio2 = src.RATIO2; } if (mProj == null) //新增工程信息 { // 检查OBJECTNAME(工程名称)是否重复? TB_PROJECT proj = new TB_PROJECT(); proj.OBJECTNAME = this.txtOBJECTNAME.Text; proj.CONTRACTNO = this.txtCONTRACTNO.Text; proj.COMPANYNAME = this.txtCOMPANYNAME.Text; proj.ADDRESS = this.txtADDRESS.Text; proj.BEGINDATE = this.dtpBeginDate.DateTime; proj.ENDDATE = this.dtpEndDate.DateTime; proj.OBJECTTYPENAME = getProjidentity(); proj.MONEY = decimal.Parse(this.txtMoney.Text); //折扣 proj.ZHEKOU = decimal.Parse(txtZHKOU.Text); //if (this.chkBillStatus.IsChecked == true) //{ // proj.BILLSTATUS = "已结算"; // proj.BILLDATE = TableManager.DBServerTime(); //} //负责人 if (txtleder.Tag != null && (txtleder.Tag as TB_User).USER_NAME == txtleder.Text) { proj.TEAMLEDER = (txtleder.Tag as TB_User).USER_CODE.ToString(); proj.TEAMLEDERNAME = (txtleder.Tag as TB_User).USER_NAME; } //成员 proj.TEAMMEMBER = getTeamMember(); //发票 proj.MEMO = this.txtMemo.Text; proj.CREATEUSER = Global.g_usercode; //创建者 proj.RATIO1 = ratio1; proj.RATIO2 = ratio2; proj.Save(); MessageHelper.ShowMessage("保存成功!"); } else //更新工程信息 { //判断是否已有报销信息,如果有报销信息项目不能再更新 //TB_EXPENSE[] arr = TB_EXPENSEDAO.FindAll(new EqExpression("OBJECTID", mProj.Id), new EqExpression("STATUS", 1)); //if (arr.Length > 0 && Global.g_userrole != 9) //{ // if (arr.Length == 1 && arr[0].EXPENS == "管理费") // { } // else // { // MessageHelper.ShowMessage("该项目已有报销信息,不能再更新项目信息!"); // return; // } //} mProj.OBJECTNAME = this.txtOBJECTNAME.Text; mProj.CONTRACTNO = this.txtCONTRACTNO.Text; mProj.COMPANYNAME = this.txtCOMPANYNAME.Text; mProj.ADDRESS = this.txtADDRESS.Text; mProj.BEGINDATE = this.dtpBeginDate.DateTime; mProj.ENDDATE = this.dtpEndDate.DateTime; mProj.OBJECTTYPENAME = getProjidentity(); mProj.MONEY = decimal.Parse(this.txtMoney.Text); //折扣 mProj.ZHEKOU = decimal.Parse(txtZHKOU.Text); //负责人 if (txtleder.Tag != null && (txtleder.Tag as TB_User).USER_NAME == txtleder.Text) { mProj.TEAMLEDER = (txtleder.Tag as TB_User).USER_CODE.ToString(); mProj.TEAMLEDERNAME = (txtleder.Tag as TB_User).USER_NAME; } //成员 mProj.TEAMMEMBER = getTeamMember(); //发票 mProj.MEMO = this.txtMemo.Text; //项目更新操作不更新全局提成比率 //mProj.RATIO1 = ratio1; //mProj.RATIO2 = ratio2; mProj.Update(); MessageHelper.ShowMessage("保存成功!"); } #region 发票信息处理 //先把工程对应的所有发票全部作废,再重新新增 //TB_PROJECT temp = TB_PROJECTDAO.FindFirst(new EqExpression("OBJECTNAME", txtOBJECTNAME.Text)); //BaseBusiness bb = new BaseBusiness(); //bool rtn = bb.DelALLItem("TB_BILL", "PROJECTID=" + temp.Id + ""); //List<TB_BILL> ls = getBills(); //if (ls.Count > 0) //{ // if (rtn == true) // { // for (int i = 0; i < ls.Count; i++) // { // TB_BILL bill = new TB_BILL(); // bill.CREATEDATE = ls[i].CREATEDATE; // bill.BILLNUMBER = ls[i].BILLNUMBER; // bill.PROJECTID = temp.Id; // bill.MONEY = ls[i].MONEY; // bill.STATUS = 1; // bill.Save(); // } // } // else // { // MessageHelper.ShowMessage("保存发票信息发生错误!"); // } //} #endregion } catch (Exception ex) { MessageHelper.ShowMessage(ex.Message); } }
private void btnSubmit_Click(object sender, RoutedEventArgs e) { try { //获取提成全局设置信息: decimal ratio1 = Global.g_ratio1; //Utils.NvDecimal(PTS_TABLE_SRCDAO.FindFirst(new EqExpression("TABLE_ID", "PTS_TABLE_RATIO"), new EqExpression("TABLE_NAME", "固定均分提成比例")).TABLE_VALUE); decimal ratio2 = Global.g_ratio2; //Utils.NvDecimal(PTS_TABLE_SRCDAO.FindFirst(new EqExpression("TABLE_ID", "PTS_TABLE_RATIO"), new EqExpression("TABLE_NAME", "可分配提成比率")).TABLE_VALUE); if (mProj == null) //新增工程信息 { //检查OBJECTNAME(工程名称)是否重复? if (!string.IsNullOrEmpty(txtOBJECTNAME.Text)) { TB_PROJECT[] existProj = TB_PROJECTDAO.FindAll(new EqExpression("STATUS", 1), new EqExpression("OBJECTNAME", this.txtOBJECTNAME.Text)); if (existProj.Length > 0) { MessageHelper.ShowMessage("项目名称有重复,请检查"); this.txtOBJECTNAME.Focus(); return; } } else { MessageHelper.ShowMessage("请填写项目名称"); return; } TB_PROJECT proj = new TB_PROJECT(); proj.OBJECTNAME = this.txtOBJECTNAME.Text; proj.CONTRACTNO = this.txtCONTRACTNO.Text; proj.COMPANYNAME = this.txtCOMPANYNAME.Text; proj.ADDRESS = this.txtADDRESS.Text; proj.BEGINDATE = this.dtpBeginDate.DateTime; proj.ENDDATE = this.dtpEndDate.DateTime; proj.OBJECTTYPENAME = getProjidentity(); proj.MONEY = decimal.Parse(this.txtMoney.Text); //折扣 //proj.ZHEKOU = decimal.Parse(txtZHKOU.Text); if (this.chkBillStatus.IsChecked == true) { proj.BILLSTATUS = "已结算"; proj.BILLDATE = TableManager.DBServerTime(); } //负责人 if (txtleder.Tag != null && (txtleder.Tag as TB_User).USER_NAME == txtleder.Text) { proj.TEAMLEDER = (txtleder.Tag as TB_User).USER_CODE.ToString(); proj.TEAMLEDERNAME = (txtleder.Tag as TB_User).USER_NAME; } //成员 proj.TEAMMEMBER = getTeamMember(); //发票 proj.MEMO = this.txtMemo.Text; proj.CREATEUSER = Global.g_usercode; //创建者 proj.RATIO1 = ratio1; proj.RATIO2 = ratio2; proj.Save(); #region 项目管理费 //根据工程金额保存管理费 TB_EXPENSE exp = new TB_EXPENSE(); exp.MONEY = RatioBusiness.QueryProjCost(decimal.Parse(this.txtMoney.Text)); exp.EXPENS = "管理费"; exp.EXPENSTYPE = 16; exp.OPUID = 0; exp.OBJECTID = TB_PROJECTDAO.FindFirst(new EqExpression("OBJECTNAME", proj.OBJECTNAME)).Id; exp.Save(); #endregion MessageHelper.ShowMessage("保存成功!"); } else //更新工程信息 { //判断是否已有报销信息,如果有报销信息项目不能再更新 TB_EXPENSE[] arr = TB_EXPENSEDAO.FindAll(new EqExpression("OBJECTID", mProj.Id), new EqExpression("STATUS", 1)); if (arr.Length > 0 && Global.g_userrole != 9) { MessageHelper.ShowMessage("该项目已有报销信息,不能再更新项目信息!"); return; } else if (arr.Length == 0 && Global.g_userrole != 9) { mProj.OBJECTNAME = this.txtOBJECTNAME.Text; mProj.CONTRACTNO = this.txtCONTRACTNO.Text; mProj.COMPANYNAME = this.txtCOMPANYNAME.Text; mProj.ADDRESS = this.txtADDRESS.Text; mProj.BEGINDATE = this.dtpBeginDate.DateTime; mProj.ENDDATE = this.dtpEndDate.DateTime; mProj.OBJECTTYPENAME = getProjidentity(); mProj.MONEY = decimal.Parse(this.txtMoney.Text); //折扣 //mProj.ZHEKOU = decimal.Parse(txtZHKOU.Text); if (this.chkBillStatus.IsChecked == true) { mProj.BILLSTATUS = "已结算"; mProj.BILLDATE = TableManager.DBServerTime(); } else { mProj.BILLSTATUS = ""; } //负责人 if (txtleder.Tag != null && (txtleder.Tag as TB_User).USER_NAME == txtleder.Text) { mProj.TEAMLEDER = (txtleder.Tag as TB_User).USER_CODE.ToString(); mProj.TEAMLEDERNAME = (txtleder.Tag as TB_User).USER_NAME; } //成员 mProj.TEAMMEMBER = getTeamMember(); //发票 mProj.MEMO = this.txtMemo.Text; mProj.RATIO1 = ratio1; mProj.RATIO2 = ratio2; mProj.Update(); } MessageHelper.ShowMessage("保存成功!"); } #region 发票信息处理 //先把工程对应的所有发票全部作废,再重新新增 TB_PROJECT temp = TB_PROJECTDAO.FindFirst(new EqExpression("OBJECTNAME", txtOBJECTNAME.Text)); BaseBusiness bb = new BaseBusiness(); bool rtn = bb.DelALLItem("TB_BILL", "PROJECTID=" + temp.Id + ""); List <TB_BILL> ls = getBills(); if (ls.Count > 0) { if (rtn == true) { for (int i = 0; i < ls.Count; i++) { TB_BILL bill = new TB_BILL(); bill.CREATEDATE = ls[i].CREATEDATE; bill.BILLNUMBER = ls[i].BILLNUMBER; bill.PROJECTID = temp.Id; bill.MONEY = ls[i].MONEY; bill.STATUS = 1; bill.Save(); } } else { MessageHelper.ShowMessage("保存发票信息发生错误!"); } } #endregion } catch (Exception ex) { MessageHelper.ShowMessage(ex.Message); } }