private void rationProcess() { if (mproj != null) { if (string.IsNullOrEmpty(mproj.BILLSTATUS)) { labMyMoney.Content = "待结算"; return; } profileporcess pp = new profileporcess(); projProfileClass ppc = pp.getProfile(TB_PROJECTDAO.FindFirst(new EqExpression("Id", mprojID))); List <TB_PERSONAL_PROFILE> list = pp.personalProcess(ppc, mprojID); if (list.Count > 0) { List <TB_PERSONAL_PROFILE> rtn = list.FindAll(a => a.USERCODE == Global.g_usercode); //数据过滤 if (rtn.Count > 0) { labMyMoney.Content = rtn[0].PROFILE1 + rtn[0].PROFILE2 + "元"; } else { labMyMoney.Content = "0元"; } } else { labMyMoney.Content = "0元"; } } }
private void BindProjectInfo() { try { if (mprojID > 0) { mproj = TB_PROJECTDAO.FindFirst(new EqExpression("Id", mprojID)); if (mproj != null) { this.labCustomer.Content = mproj.COMPANYNAME; this.labLeader.Content = mproj.TEAMLEDERNAME; //this.labMoney.Content = mproj.MONEY; this.labProjDate.Content = mproj.BEGINDATE.ToShortDateString() + "-" + mproj.ENDDATE.ToShortDateString(); this.labProjName.Content = mproj.OBJECTNAME; this.labProjType.Content = Comments.Comment.setProjIdentity(mproj.OBJECTTYPENAME); //this.labMember.Content = mproj.TEAMMEMBER.Replace('|', ' '); //this.labJS.Content = mproj.BILLSTATUS; //this.labJS.Visibility = System.Windows.Visibility.Visible; } } } catch (Exception ex) { MessageHelper.ShowMessage(ex.Message); } }
private void BindExpenseData2() { mEList = new List <TB_EXPENSE>(); this.dgExpense.ItemsSource = null; try { if (mExp.OBJECTID == 0) { this.rdoPersinal.IsChecked = true; //个人报销 TB_EXPENSE[] arr = TB_EXPENSEDAO.FindAll(new EqExpression("OBJECTID", 0), new EqExpression("STATUS", 1)); if (arr != null && arr.Length > 0) { mEList = new List <TB_EXPENSE>(arr); } } else { this.jt.IsEnabled = false; this.cb.IsEnabled = false; this.qt.IsEnabled = false; this.tx.IsEnabled = false; this.rdoObject.IsChecked = true; TB_PROJECT proj = TB_PROJECTDAO.FindFirst(new EqExpression("Id", mExp.OBJECTID)); if (proj != null) { this.txtProj.Tag = proj; this.txtProj.Text = proj.OBJECTNAME; //项目报销 TB_EXPENSE[] arr = TB_EXPENSEDAO.FindAll(new EqExpression("OBJECTID", (txtProj.Tag as TB_PROJECT).Id), new EqExpression("STATUS", 1)); if (arr != null && arr.Length > 0) { mEList = new List <TB_EXPENSE>(arr); } } } mEList = mEList.FindAll(a => a.MONTH == MONTH && a.YEAR == YEAR); this.dgExpense.ItemsSource = screening(mEList); this.txtMoney.Text = this.mExp.MONEY.ToString(); this.txtFPHM.Text = this.mExp.BILLNO; this.cmbExprenseItem.Text = mExp.EXPENS; this.txtComments.Text = mExp.COMMENTS; if (mExp.ISQTCT == 1) { this.chkQTCT.IsEnabled = true; this.chkQTCT.IsChecked = true; this.txtCusName.Text = mExp.OPNAME; } this.btnSubmit.Content = "修 改"; } catch (Exception ex) { this.btnSubmit.Content = "新 增"; MessageHelper.ShowMessage(ex.Message); } }
public List <TB_PERSONAL_PROFILE> personalProcess(projProfileClass ppc, int projId) { decimal money = ppc.xmgcstje; //总项目工程师提成金额 List <TB_PERSONAL_PROFILE> rtn = new List <TB_PERSONAL_PROFILE>(); try { TB_PROJECT proj = TB_PROJECTDAO.FindFirst(new EqExpression("Id", projId)); if (proj != null) { TB_RATIO[] arr = TB_RATIODAO.FindAll(new EqExpression("PROJECTID", projId), new EqExpression("STATUS", 1)); if (arr.Length > 0) { decimal totalAmount = 0; for (int i = 0; i < arr.Length; i++) { totalAmount += arr[i].RATIO; } //全局提成比率 decimal ratio1 = proj.RATIO1 / 100; decimal ratio2 = proj.RATIO2 / 100; //分配全局 decimal _money60 = Math.Round(money * ratio1, 2); decimal _money40 = Math.Round(money * ratio2, 2); decimal avgmoney60 = Math.Round(_money60 / arr.Length, 2); //均分提成 //个人提成份额 for (int i = 0; i < arr.Length; i++) { TB_PERSONAL_PROFILE tpp = new TB_PERSONAL_PROFILE(); tpp.USERCODE = arr[i].USERCODE; tpp.AMOUNT = arr[i].RATIO; tpp.PROFILE1 = avgmoney60; tpp.PROFILE2 = Math.Round(_money40 / totalAmount * arr[i].RATIO, 2); rtn.Add(tpp); } } } else { return(rtn); } } catch (Exception ex) { MessageHelper.ShowMessage(ex.Message); } return(rtn); }
private void BindExpenseData2() { mEList = new List <TB_EXPENSE>(); this.dgExpense.ItemsSource = null; try { if (mExp.OBJECTID == 0) { this.rdoPersinal.IsChecked = true; //个人报销 TB_EXPENSE[] arr = TB_EXPENSEDAO.FindAll(new EqExpression("OBJECTID", 0), new EqExpression("STATUS", 1)); if (arr != null && arr.Length > 0) { mEList = new List <TB_EXPENSE>(arr); } } else { this.jt.IsEnabled = false; this.cb.IsEnabled = false; this.qt.IsEnabled = false; this.tx.IsEnabled = false; this.rdoObject.IsChecked = true; TB_PROJECT proj = TB_PROJECTDAO.FindFirst(new EqExpression("Id", mExp.OBJECTID)); if (proj != null) { this.txtProj.Tag = proj; this.txtProj.Text = proj.OBJECTNAME; //项目报销 TB_EXPENSE[] arr = TB_EXPENSEDAO.FindAll(new EqExpression("OBJECTID", (txtProj.Tag as TB_PROJECT).Id), new EqExpression("STATUS", 1)); if (arr != null && arr.Length > 0) { mEList = new List <TB_EXPENSE>(arr); } } } this.dtpDate.DateTime = mExp.CREATEDATE; this.dgExpense.ItemsSource = screening(mEList); this.txtMoney.Text = this.mExp.MONEY.ToString(); this.txtFPHM.Text = this.mExp.BILLNO; this.cmbExprenseItem.Text = mExp.EXPENS; } catch (Exception ex) { MessageHelper.ShowMessage(ex.Message); } }
/// <summary> /// 查询已结算项目的成员提成 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnSearch_Click(object sender, RoutedEventArgs e) { dgProfile.ItemsSource = null; if (this.txtProj.Tag == null) { MessageHelper.ShowMessage("请选择需要查询的项目"); return; } else { TB_PROJECT proj = this.txtProj.Tag as TB_PROJECT; if (proj.BILLSTATUS == "已结算") { profileporcess pp = new profileporcess(); projProfileClass ppc = pp.getProfile(TB_PROJECTDAO.FindFirst(new EqExpression("Id", proj.Id))); List <TB_PERSONAL_PROFILE> list = pp.personalProcess(ppc, proj.Id); List <TB_PERSONAL_PROFILE> _list = new List <TB_PERSONAL_PROFILE>(); if (txtUser.Tag == null) { _list = list; } else { TB_User user = txtUser.Tag as TB_User; _list = list.FindAll(a => a.USERCODE == user.USER_CODE); } if (_list.Count > 0) { for (int i = 0; i < _list.Count; i++) { _list[i].INDEX = i + 1; _list[i].USERNAME = TB_UserDao.FindFirst(new EqExpression("USER_CODE", _list[i].USERCODE)).USER_NAME; } dgProfile.ItemsSource = list; } } else { MessageHelper.ShowMessage("该项目未结算"); return; } } }
public ucPreview2(int _projectID) { InitializeComponent(); if (_projectID == 0) { return; } mprojID = _projectID; this.dgExpense.ItemsSource = null; Query(); //报销信息查询 BindProjectInfo(); QueryBillInfo(); profileporcess pp = new profileporcess(); projProfileClass ppc = pp.getProfile(TB_PROJECTDAO.FindFirst(new EqExpression("Id", mprojID))); profileProcess(ppc); //项目利润计算 this.panel.Children.Clear(); rationProcess(ppc); //个人提成计算 }
private void Row_MouseRightButtonDown(object sender, MouseButtonEventArgs e) { menuEdit.Visibility = System.Windows.Visibility.Collapsed; menuPass.Visibility = System.Windows.Visibility.Collapsed; menuEdit2.Visibility = System.Windows.Visibility.Collapsed; menuPass2.Visibility = System.Windows.Visibility.Collapsed; TB_EXPENSE expense = (TB_EXPENSE)dgExpense.SelectedItem; if (expense != null) { //TB_PROJECT proj = this.txtProj.Tag as TB_PROJECT; //工程 TB_PROJECT proj = TB_PROJECTDAO.FindFirst(new EqExpression("Id", expense.OBJECTID)); if (proj != null) //项目报销 { //总经理 if (Global.g_userrole == 8 || Global.g_usercode == proj.CREATEUSER) { menuEdit2.Visibility = System.Windows.Visibility.Visible; menuPass2.Visibility = System.Windows.Visibility.Visible; } else if (Global.g_userrole == 9) { menuEdit.Visibility = System.Windows.Visibility.Visible; menuPass.Visibility = System.Windows.Visibility.Visible; } } else //个人报销 { if (Global.g_userrole == 9) { menuEdit.Visibility = System.Windows.Visibility.Visible; menuPass.Visibility = System.Windows.Visibility.Visible; } } } }
/// <summary> /// 财务更新工程按钮 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnSubmit2_Click(object sender, RoutedEventArgs e) { try { TB_PROJECT tempProj = TB_PROJECTDAO.FindFirst(new EqExpression("OBJECTNAME", txtOBJECTNAME.Text), new EqExpression("STATUS", 1)); //更新发票信息 #region 发票信息处理 //先把工程对应的所有发票全部作废,再重新新增 BaseBusiness bb = new BaseBusiness(); bool rtn = bb.DelALLItem("TB_BILL", "PROJECTID=" + tempProj.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 = tempProj.Id; bill.MONEY = ls[i].MONEY; bill.STATUS = 1; bill.Save(); } } else { MessageHelper.ShowMessage("保存发票信息发生错误!"); return; } } #endregion //更新结算信息 if (this.chkBillStatus.IsChecked == true) { if (MessageBox.Show("是否确定该项目执行结算?\n如果确定结算,该项目不能再做任何操作!", "提示", MessageBoxButton.YesNo, MessageBoxImage.Warning) == MessageBoxResult.Yes) { tempProj.BILLSTATUS = "已结算"; tempProj.BILLDATE = TableManager.DBServerTime(); tempProj.Update(); //根据合同价计算项目管理费用 decimal cost = RatioBusiness.QueryProjCost(tempProj.MONEY); //项目成本金额 TB_EXPENSE expense = new TB_EXPENSE(); expense.MONEY = cost; expense.EXPENS = "项目管理成本"; expense.OBJECTID = tempProj.Id; expense.OBJECTNAME = tempProj.OBJECTNAME; expense.EXPENSTYPE = 99; expense.OPUID = 99; expense.OPNAME = "乾唐通信"; expense.RESPONSESTATUS = 2; expense.CREATEDATE = TableManager.DBServerTime(); expense.Save(); //保存组员提成金额 } } this.Close(); } 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); } }
private void dgSummery_MouseLeftButtonUp(object sender, MouseButtonEventArgs e) { if (dgSummery.SelectedItem != null) { TB_EXPENSE_SUMMERY item = dgSummery.SelectedItem as TB_EXPENSE_SUMMERY; foreach (KeyValuePair <TB_EXPENSE_SUMMERY, List <TB_EXPENSE> > kvp in dic) { if (kvp.Key as TB_EXPENSE_SUMMERY == item) { //TB_PROJECT proj = this.txtProj.Tag as TB_PROJECT; //工程类型 TB_PROJECT proj = TB_PROJECTDAO.FindFirst(new EqExpression("Id", item.id)); List <TB_EXPENSE> ls = new List <TB_EXPENSE>(); if (proj != null && (proj.CREATEUSER != Global.g_usercode || Global.g_userrole == 8 || Global.g_userrole == 9)) { ls = screening(kvp.Value as List <TB_EXPENSE>); } else { ls = kvp.Value as List <TB_EXPENSE>; } var sortedList = from items in ls orderby items.GROUPNO, items.Id descending select items; ls = sortedList.ToList(); //这个时候会排序 decimal totalmoney = 0; int _groupno = -1; List <string> kmls = new List <string>(); //科目名称 for (int i = 0; i < ls.Count; i++) { string _km = ls[i].EXPENS; if (!kmls.Contains(_km)) { kmls.Add(_km); } //处理成组 if (ls[i].GROUPNO > 0 && _groupno != ls[i].GROUPNO) { _groupno = ls[i].GROUPNO; ls[i].STRGROUPNO = "┓"; ls[i].grouptotal = getGroupTotal(ls, _groupno); } else if (_groupno == ls[i].GROUPNO) { ls[i].STRGROUPNO = "┃"; if (i + 1 < ls.Count && _groupno != ls[i + 1].GROUPNO) { ls[i].STRGROUPNO = "┛"; } if (i + 1 == ls.Count) { ls[i].STRGROUPNO = "┛"; } } if (ls[i].GROUPNO == 0) { ls[i].STRGROUPNO = ""; } totalmoney += ls[i].MONEY; if (ls[i].RESPONSESTATUS == 1) { ls[i].StrResponseStatus = "驳回"; } else if (ls[i].RESPONSESTATUS == 0) { ls[i].StrResponseStatus = "待审"; } else if (ls[i].RESPONSESTATUS == 2) { ls[i].StrResponseStatus = "已审"; } if (ls[i].LEADERRESPONSESTATUS == 1) { ls[i].StrLeaderResponseStatus = "驳回"; } else if (ls[i].LEADERRESPONSESTATUS == 0) { ls[i].StrLeaderResponseStatus = "待审"; } else if (ls[i].LEADERRESPONSESTATUS == 2) { ls[i].StrLeaderResponseStatus = "已审"; } } this.dgExpense.ItemsSource = ls; if (ls != null) { dgExpense.SelectedIndex = 0; } string foot = ""; for (int i = 0; i < kmls.Count; i++) { string _km = kmls[i]; List <TB_EXPENSE> _expls = ls.FindAll(a => a.EXPENS == _km); if (_expls.Count > 0) { int counts = _expls.Count; decimal kmtotal = 0; for (int j = 0; j < _expls.Count; j++) { kmtotal += _expls[j].MONEY; } foot += " " + _km + ": 共" + counts.ToString() + "张 合计金额" + kmtotal.ToString() + "元;"; } } //this.labFoot.Content = foot; //this.labTotal.Content = "共:" + ls.Count + "张 合计:" + totalmoney.ToString() + "元"; } } } }
public ExpensePrint(List <TB_EXPENSE> _ls, string start, string end, string foot) { mList = _ls; int projectId = mList[0].OBJECTID; titletable titletable = new titletable(); if (projectId > 0) //项目报销 { TB_PROJECT proj = TB_PROJECTDAO.FindFirst(new EqExpression("Id", projectId)); titletable.title = proj.OBJECTNAME + "报销单"; titletable.name = Global.g_username; } else //个人报销 { titletable.title = "个人报销单"; titletable.name = Global.g_username; } titletable.dept = Global.g_dept; titletable.date = start + "年" + end + "月"; int count = 0; decimal totalmoney = 0; for (int i = 0; i < mList.Count; i++) { totalmoney += mList[i].MONEY; count++; } string[] arr = foot.Split(';'); List <foot1> fs1 = new List <foot1>(); List <foot2> fs2 = new List <foot2>(); List <foot3> fs3 = new List <foot3>(); if (arr.Length > 0) { int idx = 1; for (int i = 0; i < arr.Length; i++) { if (idx == 1) { foot1 f1 = new foot1(); f1.strfoot1 = arr[i]; fs1.Add(f1); idx++; } else if (idx == 2) { foot2 f2 = new foot2(); f2.strfoot2 = arr[i]; fs2.Add(f2); idx++; } else if (idx == 3) { idx = 1; foot3 f3 = new foot3(); f3.strfoot3 = arr[i]; fs3.Add(f3); } } } List <foots> fs = new List <foots>(); for (int i = 0; i < fs1.Count; i++) { foots f = new foots(); f.strfoot1 = fs1[i].strfoot1; if (i < fs2.Count) { f.strfoot2 = fs2[i].strfoot2; } else { f.strfoot2 = ""; } if (i < fs3.Count) { f.strfoot3 = fs3[i].strfoot3; } else { f.strfoot3 = ""; } fs.Add(f); } titletable.summary = "合计发票共:" + count.ToString() + "张 合计金额:" + totalmoney.ToString(); List <titletable> title = new List <ReportBusiness.titletable>(); title.Add(titletable); for (int i = 0; i < mList.Count; i++) { mList[i].Index = i + 1; } reportPrint(title, mList, fs); }