Beispiel #1
0
 /// <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);
     }
 }
Beispiel #2
0
        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);
            }
        }