Exemplo n.º 1
0
 public static void SaveWorkCaseEx(DataSet workCaseDs, string caseCode, string ActCode)
 {
     try
     {
         EntityData        entitydata = WorkFlowRule.SaveWorkFlowCaseData(workCaseDs, caseCode);
         StandardEntityDAO ydao       = new StandardEntityDAO("Standard_WorkFlowCase");
         ydao.BeginTrans();
         try
         {
             if (entitydata != null)
             {
                 for (int i = entitydata.Tables["WorkFlowAct"].Rows.Count - 1; i >= 0; i--)
                 {
                     if (ActCode == entitydata.Tables["WorkFlowAct"].Rows[i]["ActCode"].ToString())
                     {
                         entitydata.Tables["WorkFlowAct"].Rows[i].Delete();
                     }
                 }
                 ydao.SubmitEntity(entitydata);
             }
             ydao.CommitTrans();
         }
         catch (Exception exception)
         {
             ydao.RollBackTrans();
             throw exception;
         }
         entitydata.Dispose();
     }
     catch
     {
         throw;
     }
 }
Exemplo n.º 2
0
        public static void SubmitAllStandard_ConstructProgress(EntityData entity)
        {
            Exception exception;

            try
            {
                using (StandardEntityDAO ydao = new StandardEntityDAO("Standard_ConstructProgress"))
                {
                    ydao.BeginTrans();
                    try
                    {
                        ydao.SubmitEntity(entity);
                        ydao.CommitTrans();
                    }
                    catch (Exception exception1)
                    {
                        exception = exception1;
                        ydao.RollBackTrans();
                        throw exception;
                    }
                }
            }
            catch (Exception exception2)
            {
                exception = exception2;
                throw exception;
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// 编辑数据
        /// </summary>
        public void ModifyData()
        {
            try
            {
                BiddingSupplier cbiddingSupplier = new BiddingSupplier();
                cbiddingSupplier.dao = this.dao;
                cbiddingSupplier.BiddingPrejudicationCode = this.BiddingForwardPrejudicationCode;
                cbiddingSupplier.Flag = "1";
                EntityData entitydata = cbiddingSupplier._GetBiddingSuppliers();

                foreach (DataRow dr in entitydata.CurrentTable.Select())
                {
                    dr["flag"] = "0";
                }

                if (dao != null)
                {
                    dao.SubmitEntity(entitydata);
                }
                else
                {
                    using (dao = new StandardEntityDAO("BiddingSupplier"))
                    {
                        dao.SubmitEntity(entitydata);
                    }
                }


                int iCount = this.dgList.Items.Count;
                for (int i = 0; i < iCount; i++)
                {
                    string strCode  = this.dgList.Items[i].Cells[0].Text.Trim();
                    string strValue = ((HtmlInputText)this.dgList.Items[i].Cells[11].FindControl("txtNominateUser")).Value.Trim();

                    //if( ""==strValue )
                    //{
                    //    Response.Write( Rms.Web.JavaScript.Alert(true,"请填写提名人!") );
                    //    return;
                    //}

                    BLL.BiddingSupplier cbs = new RmsPM.BLL.BiddingSupplier();
                    cbs.dao = dao;
                    cbs.BiddingSupplierCode = strCode;
                    cbs.NominateUser        = strValue;
                    cbs.BiddingSupplierUpdate();
                }
            }
            catch (Exception ex)
            {
                ApplicationLog.WriteLog(this.ToString(), ex, "");
            }
        }
Exemplo n.º 4
0
 public static void SaveContractAuditing(DataSet workCaseDs, EntityData applicationEntity, EntityData contractEntity, string caseCode)
 {
     try
     {
         EntityData        entitydata = WorkFlowRule.SaveWorkFlowCaseData(workCaseDs, caseCode);
         StandardEntityDAO ydao       = new StandardEntityDAO("Standard_WorkFlowCase");
         ydao.BeginTrans();
         try
         {
             try
             {
                 if (entitydata != null)
                 {
                     ydao.SubmitEntity(entitydata);
                 }
                 ydao.EntityName = "WorkFlow_Leave";
                 ydao.SubmitEntity(applicationEntity);
                 ydao.EntityName = "Standard_Contract";
                 ydao.SubmitEntity(contractEntity);
                 ydao.CommitTrans();
             }
             catch (Exception exception)
             {
                 ydao.RollBackTrans();
                 throw exception;
             }
         }
         finally
         {
             ydao.Dispose();
         }
         entitydata.Dispose();
     }
     catch
     {
         throw;
     }
 }
Exemplo n.º 5
0
 public static void Update(StampDuty StampDuty)
 {
     using (StandardEntityDAO ydao = new StandardEntityDAO("StampDuty"))
     {
         EntityData entitydata = ydao.SelectbyPrimaryKey(StampDuty.StampDutyID);
         DataRow    currentRow = entitydata.CurrentRow;
         currentRow["TaxItems"] = StampDuty.TaxItems;
         currentRow["Range"]    = StampDuty.Range;
         currentRow["TaxRate"]  = StampDuty.TaxRate;
         currentRow["TaxPayer"] = StampDuty.TaxPayer;
         currentRow["Remarks"]  = StampDuty.Remarks;
         ydao.SubmitEntity(entitydata);
     }
 }
Exemplo n.º 6
0
 public static void DeleteStandard_SupplierSurveyOpinion(EntityData entity)
 {
     try
     {
         using (StandardEntityDAO ydao = new StandardEntityDAO("SupplierSurveyOpinion"))
         {
             ydao.SubmitEntity(entity);
         }
     }
     catch (Exception exception)
     {
         throw exception;
     }
 }
Exemplo n.º 7
0
 public static void DeleteStandard_TC_OA_BiddingContract(EntityData entity)
 {
     try
     {
         using (StandardEntityDAO ydao = new StandardEntityDAO("TC_OA_BiddingContract"))
         {
             ydao.SubmitEntity(entity);
         }
     }
     catch (Exception exception)
     {
         throw exception;
     }
 }
Exemplo n.º 8
0
 public static void DeleteStandard_Grade(EntityData entity)
 {
     try
     {
         using (StandardEntityDAO ydao = new StandardEntityDAO("Grade"))
         {
             ydao.SubmitEntity(entity);
         }
     }
     catch (Exception exception)
     {
         throw exception;
     }
 }
Exemplo n.º 9
0
        /// ****************************************************************************
        /// <summary>
        /// 删除按钮事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        /// ****************************************************************************
        protected void btnDel_ServerClick(object sender, System.EventArgs e)
        {
            try
            {
                //if (this.ApplicationCode != "")
                //{

                //}
                //if (this.BiddingDtlModify1.ApplicationCode != "")
                //    this.BiddingDtlModify1.Delete();
                if (this.WorkFlowList1.WorkFlowCount == 0)
                {
                    RmsPM.BLL.BiddingPrejudication cbiddingPrejudication = new RmsPM.BLL.BiddingPrejudication();
                    cbiddingPrejudication.BiddingCode = this.Bidding1.ApplicationCode;
                    EntityData entityPrejudication = cbiddingPrejudication._GetBiddingPrejudications();
                    entityPrejudication.DeleteAllTableRow("BiddingPrejudication");
                    using (StandardEntityDAO dao = new StandardEntityDAO("BiddingPrejudication"))
                    {
                        dao.SubmitEntity(entityPrejudication);
                    }
                    if (this.BiddingDtlModify1.ApplicationCode != "")
                    {
                        this.BiddingDtlModify1.Delete();
                    }
                    Bidding1.Delete();
                }



                if (Request["FunctionName"] != null)
                {
                    Response.Write(Rms.Web.JavaScript.ScriptStart);
                    Response.Write("window.opener." + Request["FunctionName"].ToString() + "();");
                    Response.Write(Rms.Web.JavaScript.WinClose(false));
                    Response.Write(Rms.Web.JavaScript.ScriptEnd);
                }
                else
                {
                    Response.Write(Rms.Web.JavaScript.ScriptStart);
                    Response.Write("window.opener.location.reload();");
                    Response.Write(Rms.Web.JavaScript.WinClose(false));
                    Response.Write(Rms.Web.JavaScript.ScriptEnd);
                }
            }
            catch (Exception ex)
            {
                Response.Write(Rms.Web.JavaScript.Alert(true, ex.ToString()));
            }
        }
    public override bool Delete(StandardEntityDAO dao)
    {
        if (this.ApplicationCode != "")
        {
            this.OperationCode = RmsPM.BLL.ContractRule.GetContractCodeByAccountCode(this.ApplicationCode);
        }
        else if (this.OperationCode != "")
        {
            this.ApplicationCode = RmsPM.DAL.EntityDAO.SystemManageDAO.GetNewSysCode("ContractAccountCode");
        }
        else
        {
            return(false);
        }

        this.ContractCode = this.OperationCode;

        EntityData entity = RmsPM.DAL.EntityDAO.ContractDAO.GetStandard_ContractByCode(this.ContractCode);

        //RmsPM.BLL.ContractRule.ContractStatusChange(this.ContractCode, 2);

        foreach (DataRow dr in entity.Tables["ContractAccount"].Select(String.Format("ContractAccountCode='{0}'", this.ApplicationCode), "", DataViewRowState.CurrentRows))
        {
            dr["Status"] = 1;

            if (!String.IsNullOrEmpty(dr["contractchangeid"].ToString()))
            {
                DataRow[] drs = entity.Tables["Contractchange"].Select(String.Format("contractchangecode='{0}'", dr["contractchangeid"].ToString(), "", DataViewRowState.CurrentRows));
                if (drs.Length >= 1)
                {
                    drs[0]["status"] = 1;
                }
            }
        }

        dao.SubmitEntity(entity);


        return(base.Delete(dao));
    }
Exemplo n.º 11
0
        /// <summary>
        /// 将上一次的投标预审通过的单位移到当前单位预审中
        /// </summary>
        /// <returns></returns>
        public void MovePassByPrejudication()
        {
            try
            {
                BiddingSupplier cbiddingSupplier = new BiddingSupplier();
                cbiddingSupplier.BiddingPrejudicationCode = this.BiddingForwardPrejudicationCode;
                cbiddingSupplier.Flag = "1";
                EntityData entitydata = cbiddingSupplier._GetBiddingSuppliers();

                foreach (DataRow dr in entitydata.CurrentTable.Select())
                {
                    DataRow newdr = entitydata.GetNewRecord();

                    BLL.ConvertRule.DataRowCopy(dr, newdr, entitydata.CurrentTable, entitydata.CurrentTable);

                    newdr["BiddingSupplierCode"]      = DAL.EntityDAO.SystemManageDAO.GetNewSysCode("BiddingSupplier");
                    newdr["BiddingPrejudicationCode"] = this.BiddingPrejudicationCode;
                    entitydata.CurrentTable.Rows.Add(newdr);
                    BLL.BiddingSystem.InsertDepartMent(newdr["BiddingPrejudicationCode"].ToString(), newdr["BiddingSupplierCode"].ToString());
                }

                if (dao != null)
                {
                    dao.SubmitEntity(entitydata);
                }
                else
                {
                    using (dao = new StandardEntityDAO("BiddingSupplier"))
                    {
                        dao.SubmitEntity(entitydata);
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemplo n.º 12
0
 public static void SaveWorkCaseEx(DataSet workCaseDs, string caseCode)
 {
     try
     {
         EntityData        entitydata = WorkFlowRule.SaveWorkFlowCaseData(workCaseDs, caseCode);
         StandardEntityDAO ydao       = new StandardEntityDAO("Standard_WorkFlowCase");
         try
         {
             if (entitydata != null)
             {
                 ydao.SubmitEntity(entitydata);
             }
         }
         catch (Exception exception)
         {
             throw exception;
         }
         entitydata.Dispose();
     }
     catch
     {
         throw;
     }
 }
Exemplo n.º 13
0
        /// <summary>
        /// 保存
        /// </summary>
        private void SavaData()
        {
            try
            {
                //主表
                EntityData entity = DAL.EntityDAO.PurchaseFlowDAO.GetPurchaseFlowByCode(this.txtPurchaseFlowCode.Value);
                DataRow    dr     = null;
                if (!entity.HasRecord())                 //新增
                {
                    this.txtPurchaseFlowCode.Value = RmsPM.DAL.EntityDAO.SystemManageDAO.GetNewSysCode("PurchaseFlow");

                    dr = entity.CurrentTable.NewRow();
                    dr["PurchaseFlowCode"] = this.txtPurchaseFlowCode.Value;
                    dr["ProjectCode"]      = this.txtProjectCode.Value;
                    dr["CreateDate"]       = DateTime.Today;

                    dr["State"] = 0;

                    entity.CurrentTable.Rows.Add(dr);
                }
                else
                {
                    dr = entity.CurrentRow;
                }

                dr["Purpose"] = this.txtPurpose.Value;

                //明细
                EntityData entityDtl = DAL.EntityDAO.PurchaseFlowDAO.GetPurchaseFlowDetailByCode(this.txtPurchaseFlowDetailCode.Value);
                DataRow    drDtl     = null;
                if (!entityDtl.HasRecord())
                {
                    this.txtPurchaseFlowDetailCode.Value = RmsPM.DAL.EntityDAO.SystemManageDAO.GetNewSysCode("PurchaseFlowDetail");

                    drDtl = entityDtl.CurrentTable.NewRow();
                    drDtl["PurchaseFlowCode"] = this.txtPurchaseFlowCode.Value;

                    entityDtl.CurrentTable.Rows.Add(drDtl);
                }
                else
                {
                    drDtl = entityDtl.CurrentRow;
                }

                drDtl["Money"]       = BLL.ConvertRule.ToDecimal(this.txtMoney.Value);
                drDtl["Description"] = this.txtDescription.Value;

                //提交
                using (StandardEntityDAO dao = new StandardEntityDAO("PurchaseFlow"))
                {
                    dao.BeginTrans();
                    try
                    {
                        //提交主表
                        dao.SubmitEntity(entity);

                        //提交明细
                        dao.EntityName = "PurchaseFlowDetail";
                        dao.SubmitEntity(entityDtl);

                        dao.CommitTrans();
                    }
                    catch (Exception ex)
                    {
                        try
                        {
                            //RollBackTrans会报错:此 SqlTransaction 已完成;它再也无法使用
                            dao.RollBackTrans();
                        }
                        catch
                        {
                        }

                        throw ex;
                    }
                }

                entity.Dispose();
                entityDtl.Dispose();
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemplo n.º 14
0
        /// <summary>
        /// 保存
        /// </summary>
        private void SavaData()
        {
            try
            {
                string CostBudgetSetCode = this.txtCostBudgetSetCode.Value;
                string CostBudgetCode;

                //取当前预算设置表的所有费用项
                EntityData entityAllCBS = BLL.CostBudgetRule.GetAllCBSBySet(this.txtProjectCode.Value, this.txtCostBudgetSetCode.Value);

                //保存动态费用表
                EntityData entity = BLL.CostBudgetRule.GetValidCostBudget(CostBudgetSetCode, 0);
                bool       isNew  = false;

                DataRow dr = null;
                if (!entity.HasRecord())
                {
                    isNew          = true;
                    CostBudgetCode = RmsPM.DAL.EntityDAO.SystemManageDAO.GetNewSysCode("CostBudgetCode");

                    dr = entity.CurrentTable.NewRow();
                    dr["CostBudgetCode"]    = CostBudgetCode;
                    dr["CostBudgetSetCode"] = CostBudgetSetCode;
                    dr["ProjectCode"]       = this.txtProjectCode.Value;

                    dr["Status"]              = 1;
                    dr["TargetFlag"]          = 0;
                    dr["FirstCostBudgetCode"] = CostBudgetCode;
                    dr["VerID"] = 0;

                    entity.CurrentTable.Rows.Add(dr);
                }
                else
                {
                    CostBudgetCode = entity.GetString("CostBudgetCode");

                    dr = entity.CurrentRow;
                }

                //动态费用明细历史记录
                EntityData entityDtlHis = DAL.EntityDAO.CostBudgetDAO.GetCostBudgetDtlHisByCode("");

                //动态费用明细(所有)
                EntityData entityDtl = DAL.EntityDAO.CostBudgetDAO.GetV_CostBudgetDtlByCostBudgetCode(CostBudgetCode);

                //当前一条动态费用明细
                DataRow[] drs = entityDtl.CurrentTable.Select("CostCode = '" + this.txtCostCode.Value + "'");
                DataRow   drDtl;
                if (drs.Length <= 0)
                {
                    drDtl = entityDtl.CurrentTable.NewRow();

                    drDtl["CostBudgetDtlCode"] = RmsPM.DAL.EntityDAO.SystemManageDAO.GetNewSysCode("CostBudgetDtlCode");
                    drDtl["CostBudgetCode"]    = CostBudgetCode;
                    drDtl["ProjectCode"]       = this.txtProjectCode.Value;
                    drDtl["CostCode"]          = this.txtCostCode.Value;

                    //填费用项信息
                    BLL.CostBudgetPageRule.FillCostBudgetDtlCBSData(drDtl, entityAllCBS.CurrentTable);

                    entityDtl.CurrentTable.Rows.Add(drDtl);
                }
                else
                {
                    drDtl = drs[0];

                    //保存动态费用明细历史记录
                    BLL.CostBudgetRule.AddCostBudgetDtlHis(entityDtlHis.CurrentTable, drDtl, dr);
                }

                //预留金额直接录入,不要包括已定的非合同请款 xyq 2018.7.24
                drDtl["BudgetMoney"] = BLL.ConvertRule.ToDecimal(this.txtMoney.Value);

                /*
                 *              //动态费用 = 预算金额 + 已定合同
                 *              decimal money = BLL.ConvertRule.ToDecimal(this.txtMoney.Value) + BLL.ConvertRule.ToDecimal(this.txtContractMoney.Value);
                 *              drDtl["BudgetMoney"] = money;
                 */

                drDtl["Description"] = this.txtDescription.Value;

                //更新父项的动态费用
                string   FullCode    = drDtl["FullCode"].ToString();
                string[] arrCostCode = FullCode.Split("-".ToCharArray());
                for (int i = arrCostCode.Length - 2; i >= 0; i--)
                {
                    //费用项必须属于当前预算设置表
                    if (entityAllCBS.CurrentTable.Select("CostCode = '" + arrCostCode[i] + "'").Length <= 0)
                    {
                        break;
                    }

                    DataRow[] drsP = entityDtl.CurrentTable.Select("CostCode = '" + arrCostCode[i] + "'");
                    DataRow   drP;
                    if (drsP.Length > 0)
                    {
                        drP = drsP[0];
                    }
                    else
                    {
                        drP = entityDtl.CurrentTable.NewRow();

                        drP["CostBudgetDtlCode"] = RmsPM.DAL.EntityDAO.SystemManageDAO.GetNewSysCode("CostBudgetDtlCode");
                        drP["CostBudgetCode"]    = CostBudgetCode;
                        drP["ProjectCode"]       = this.txtProjectCode.Value;
                        drP["CostCode"]          = arrCostCode[i];

                        //填费用项信息
                        BLL.CostBudgetPageRule.FillCostBudgetDtlCBSData(drP, entityAllCBS.CurrentTable);

                        entityDtl.CurrentTable.Rows.Add(drP);
                    }

                    //父项的动态费用 = 子项累计
                    DataRow[] drsChild       = entityDtl.CurrentTable.Select("ParentCode = '" + drP["CostCode"].ToString() + "'");
                    decimal   SumBudgetMoney = BLL.MathRule.SumColumn(drsChild, "BudgetMoney");

                    //保存动态费用明细历史记录
                    BLL.CostBudgetRule.AddCostBudgetDtlHis(entityDtlHis.CurrentTable, drP, dr);

                    drP["BudgetMoney"] = SumBudgetMoney;
                }

                //保存主表
                if (isNew)
                {
                    dr["ModifyPerson"] = base.user.UserCode;
                    dr["ModifyDate"]   = DateTime.Now;

//					dr["CreatePerson"] = base.user.UserCode;
//					dr["CreateDate"] = DateTime.Now;
                }
                else
                {
                    dr["ModifyPerson"] = base.user.UserCode;
                    dr["ModifyDate"]   = DateTime.Now;
                }

                //保存主表的预算总额
                BLL.CostBudgetRule.SaveCostBudgetTotalBudgetMoney(entity.CurrentTable, entityDtl.CurrentTable);

                //提交
                using (StandardEntityDAO dao = new StandardEntityDAO("CostBudget"))
                {
                    dao.BeginTrans();
                    try
                    {
                        //提交主表
                        dao.SubmitEntity(entity);

                        //提交明细
                        dao.EntityName = "CostBudgetDtl";
                        dao.SubmitEntity(entityDtl);

                        //提交明细历史
                        dao.EntityName = "CostBudgetDtlHis";
                        dao.SubmitEntity(entityDtlHis);


                        dao.CommitTrans();
                    }
                    catch (Exception ex)
                    {
                        try
                        {
                            //RollBackTrans会报错:此 SqlTransaction 已完成;它再也无法使用
                            dao.RollBackTrans();
                        }
                        catch
                        {
                        }

                        throw ex;
                    }
                }

                /*
                 * DAL.EntityDAO.CostBudgetDAO.SubmitAllCostBudget(entity);
                 * DAL.EntityDAO.CostBudgetDAO.SubmitAllCostBudgetDtl(entityDtl);
                 */

                entity.Dispose();
                entityDtl.Dispose();
                entityDtlHis.Dispose();
                entityAllCBS.Dispose();
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemplo n.º 15
0
        /// <summary>
        /// 保存
        /// </summary>
        private void SaveData(DataTable tbDtl, ref bool IsNeedCheck)
        {
            try
            {
                string CostBudgetCode = this.txtCostBudgetCode.Value;
                IsNeedCheck = true;
                string ChangingCostBudgetCode = "";

                //取申请或调整中的目标费用表
                EntityData entity = DAL.EntityDAO.CostBudgetDAO.GetCostBudgetByStatus(this.txtCostBudgetSetCode.Value, 1, "0,3", false);
                if (entity.HasRecord())
                {
                    ChangingCostBudgetCode = entity.GetString("CostBudgetCode");
                }
                entity.Dispose();

                //取当前有效的目标费用
                EntityData entityValid = BLL.CostBudgetRule.GetValidCostBudget(this.txtCostBudgetSetCode.Value, 1);

                if (this.txtStatus.Value == "3")                  //调整
                {
                    IsNeedCheck = BLL.CostBudgetRule.IsCostTargetNeedCheck(this.txtCostBudgetSetCode.Value, tbDtl);
                }

                if (!IsNeedCheck)                  //无需审核时,直接更新当前有效的目标费用
                {
                    this.txtCostBudgetCode.Value = "";
                    CostBudgetCode = entityValid.GetString("CostBudgetCode");
                }

                //要保存的目标费用
                entity = RmsPM.DAL.EntityDAO.CostBudgetDAO.GetStandard_CostBudgetByCode(CostBudgetCode);

                //保存预算主表
                BLL.CostBudgetRule.SaveTempTarget(entity, entityValid, this.txtProjectCode.Value, this.txtCostBudgetSetCode.Value, BLL.ConvertRule.ToInt(this.txtStatus.Value), base.user.UserCode, this.txtCostBudgetName.Value);
                this.txtCostBudgetCode.Value = entity.GetString("CostBudgetCode");

                //保存预算明细
                BLL.CostBudgetRule.SaveCostBudgetDtl(entity, tbDtl, BLL.ConvertRule.ToString(ViewState["StartY"]), BLL.ConvertRule.ToString(ViewState["EndY"]));

                //保存主表的预算总额
                BLL.CostBudgetRule.SaveCostBudgetTotalBudgetMoney(entity.Tables["CostBudget"], entity.Tables["CostBudgetDtl"]);

                //提交
                using (StandardEntityDAO dao = new StandardEntityDAO("CostBudget"))
                {
                    dao.BeginTrans();
                    try
                    {
                        dao.SubmitEntity(entity);

                        //删除调整中的目标费用
                        if (!IsNeedCheck)
                        {
                            BLL.CostBudgetRule.DeleteChangingTarget(ChangingCostBudgetCode, dao);
                        }

                        dao.CommitTrans();
                    }
                    catch (Exception ex)
                    {
                        try
                        {
                            //RollBackTrans会报错:此 SqlTransaction 已完成;它再也无法使用
                            dao.RollBackTrans();
                        }
                        catch
                        {
                        }

                        throw ex;
                    }
                }

//				DAL.EntityDAO.CostBudgetDAO.SubmitAllStandard_CostBudget(entity);

                entity.Dispose();
                entityValid.Dispose();
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemplo n.º 16
0
        protected void btnOK_ServerClick(object sender, System.EventArgs e)
        {
            string projectCode    = Request["ProjectCode"] + "";
            string subjectSetCode = BLL.ProjectRule.GetSubjectSetCodeByProject(projectCode);

            try
            {
                if (this.txtFile.PostedFile.FileName == "")
                {
                    Response.Write(Rms.Web.JavaScript.Alert(true, "请选择文件"));
                    return;
                }

                StreamReader m_sr = new StreamReader(this.txtFile.PostedFile.InputStream, System.Text.Encoding.Default);

                //第1行是标题
                if (m_sr.Peek() >= 0)
                {
                    m_sr.ReadLine();
                }

                EntityData cbs = DAL.EntityDAO.CBSDAO.GetCBSByProject(projectCode);
//				EntityData cost = DAL.EntityDAO.CBSDAO.GetCostByProject(projectCode);

                while (m_sr.Peek() >= 0)
                {
                    string s = m_sr.ReadLine();

                    string[] sss = BLL.ImportRule.SplitCsvLine(s);

                    if (sss.Length <= 1)
                    {
                        continue;
                    }

                    string sortID = sss[0];
                    int    re     = 0;
                    Math.DivRem(sortID.Length, 2, out re);
                    if (re == 1)
                    {
                        sortID = "0" + sortID;
                    }


                    DataRow[] drsSelect = cbs.CurrentTable.Select(String.Format("SortID='{0}'", sortID));
                    DataRow   dr        = null;

                    bool isNew = (drsSelect.Length == 0);
                    if (isNew)
                    {
                        dr = cbs.GetNewRecord();
                        string costCode = DAL.EntityDAO.SystemManageDAO.GetNewSysCode("CostCode");
                        dr["CostCode"]    = costCode;
                        dr["SortID"]      = sortID;
                        dr["ProjectCode"] = projectCode;
                        string parentFullCode = "";
                        int    parentDeep     = 0;
                        string parentCode     = "";
                        string parentSortID   = "";
                        if (sortID.Length >= 2)
                        {
                            parentSortID = sortID.Substring(0, sortID.Length - 2);
                            DataRow[] drsP = cbs.CurrentTable.Select(String.Format("SortID='{0}'", parentSortID));
                            if (drsP.Length > 0)
                            {
                                parentDeep     = (int)drsP[0]["Deep"];
                                parentCode     = (string)drsP[0]["CostCode"];
                                parentFullCode = (string)drsP[0]["FullCode"];
                            }
                        }

                        int deep = parentDeep + 1;
                        dr["Deep"]           = deep;
                        dr["ParentCode"]     = parentCode;
                        dr["SubjectSetCode"] = subjectSetCode;
                        if (parentCode == "")
                        {
                            dr["FullCode"] = costCode;
                        }
                        else
                        {
                            dr["FullCode"] = parentFullCode + "-" + costCode;
                        }

                        cbs.AddNewRecord(dr);

                        /*
                         * DataRow drCost = cost.GetNewRecord();
                         * drCost["CostItemCode"] = DAL.EntityDAO.SystemManageDAO.GetNewSysCode("CostItemCode");
                         * drCost["CostCode"] = costCode;
                         * drCost["ProjectCode"] = projectCode;
                         * drCost["Flag"] = -1;
                         * drCost["TotalMoney"] = decimal.Zero;
                         * drCost["ModifyPerson"] = base.user.UserCode;
                         * drCost["ModifyDate"] = DateTime.Now.Date;
                         *
                         * // AccountPoint: 0 不作预算、1 做了预算、 2 不是控制点,是子预算统计上来的
                         *
                         * if ( deep == 1 )
                         *      drCost["AccountPoint"] = 1;
                         * else
                         *      drCost["AccountPoint"] = 0;
                         *
                         * cost.AddNewRecord(drCost);
                         */
                    }
                    else
                    {
                        dr = drsSelect[0];
                    }

                    dr["CostName"] = sss[1];

                    if (sss.Length >= 3)
                    {
                        dr["SubjectCode"] = sss[2];
                    }
                    if (sss.Length >= 4)
                    {
                        dr["CostAllocationDescription"] = sss[3];
                    }
                    if (sss.Length >= 5)
                    {
                        dr["Description"] = sss[4];
                    }
                }

                using (StandardEntityDAO dao = new StandardEntityDAO("CBS"))
                {
                    dao.BeginTrans();
                    try
                    {
                        dao.SubmitEntity(cbs);

                        /*
                         * dao.EntityName = "Cost";
                         * dao.SubmitEntity(cost);
                         */

                        dao.CommitTrans();
                    }
                    catch (Exception ex)
                    {
                        try
                        {
                            dao.RollBackTrans();
                        }
                        catch
                        {
                        }

                        throw ex;
                    }
                }

                cbs.Dispose();
//				cost.Dispose();
            }
            catch (Exception ex)
            {
                ApplicationLog.WriteLog(this.ToString(), ex, "");
                Response.Write(JavaScript.Alert(true, "导入出错:" + ex.Message));
                return;
            }

            Response.Write(JavaScript.ScriptStart);
            Response.Write(JavaScript.Alert(false, "导入完成 !"));
            Response.Write(JavaScript.OpenerReload(false));
            Response.Write("window.close();");
            Response.Write(JavaScript.ScriptEnd);
        }
Exemplo n.º 17
0
        /// <summary>
        /// 保存
        /// </summary>
        private void SavaData()
        {
            try
            {
                string CostBudgetSetCode      = this.txtCostBudgetSetCode.Value;
                string CostBudgetCode         = "";
                int    status                 = 0;
                bool   IsNeedCheck            = true;
                string ChangingCostBudgetCode = "";

                //屏幕数据保存到临时表
                EntityData entityScreen = DAL.EntityDAO.CostBudgetDAO.GetCostBudgetDtlByCode("");
                DataTable  tbScreen     = entityScreen.CurrentTable;

                DataRow drScreen = tbScreen.NewRow();
                drScreen["CostBudgetDtlCode"] = -1;
                drScreen["CostCode"]          = this.txtCostCode.Value;
                drScreen["BudgetMoney"]       = BLL.ConvertRule.ToDecimal(this.txtMoney.Value);
                drScreen["Description"]       = this.txtDescription.Value;
                tbScreen.Rows.Add(drScreen);

                DataTable tbDtl = BLL.CostBudgetRule.BuildTempTargetDtl(this.txtProjectCode.Value, this.txtCostBudgetSetCode.Value, tbScreen, ref status);
                entityScreen.Dispose();
//				DataTable tbDtl = BLL.CostBudgetRule.BuildTempTargetDtl(this.txtProjectCode.Value, this.txtCostBudgetSetCode.Value, this.txtCostCode.Value, BLL.ConvertRule.ToDecimal(this.txtMoney.Value), this.txtDescription.Value, ref status);

                //取申请或调整中的目标费用表
                EntityData entity = DAL.EntityDAO.CostBudgetDAO.GetCostBudgetByStatus(CostBudgetSetCode, 1, "0,3", false);
                if (entity.HasRecord())
                {
                    CostBudgetCode         = entity.GetString("CostBudgetCode");
                    ChangingCostBudgetCode = entity.GetString("CostBudgetCode");
                }
                entity.Dispose();

                //取当前有效的目标费用
                EntityData entityValid = BLL.CostBudgetRule.GetValidCostBudget(this.txtCostBudgetSetCode.Value, 1);

                if (status == 3)                  //调整
                {
                    IsNeedCheck = BLL.CostBudgetRule.IsCostTargetNeedCheck(this.txtCostBudgetSetCode.Value, tbDtl);
                }

                if (!IsNeedCheck)                  //无需审核时,直接更新当前有效的目标费用
                {
                    CostBudgetCode = entityValid.GetString("CostBudgetCode");
                }

                //要保存的目标费用
                entity = RmsPM.DAL.EntityDAO.CostBudgetDAO.GetStandard_CostBudgetByCode(CostBudgetCode);

                //保存预算主表
                BLL.CostBudgetRule.SaveTempTarget(entity, entityValid, this.txtProjectCode.Value, this.txtCostBudgetSetCode.Value, status, base.user.UserCode, "");

                //保存预算明细
                BLL.CostBudgetRule.SaveCostBudgetDtl(entity, tbDtl, "", "");

                //保存主表的预算总额
                BLL.CostBudgetRule.SaveCostBudgetTotalBudgetMoney(entity.Tables["CostBudget"], entity.Tables["CostBudgetDtl"]);

                //提交
                using (StandardEntityDAO dao = new StandardEntityDAO("CostBudget"))
                {
                    dao.BeginTrans();
                    try
                    {
                        dao.SubmitEntity(entity);

                        //删除调整中的目标费用
                        if (!IsNeedCheck)
                        {
                            BLL.CostBudgetRule.DeleteChangingTarget(ChangingCostBudgetCode, dao);
                        }

                        dao.CommitTrans();
                    }
                    catch (Exception ex)
                    {
                        try
                        {
                            //RollBackTrans会报错:此 SqlTransaction 已完成;它再也无法使用
                            dao.RollBackTrans();
                        }
                        catch
                        {
                        }

                        throw ex;
                    }
                }

                entity.Dispose();
                entityValid.Dispose();
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }