private static EntityData ImportSalPayByClient(string ClientCode, string ProjectCode, DataSet dsSrc, StandardEntityDAO dao) { EntityData data2; try { DataTable table = dsSrc.Tables["account"]; DataTable table2 = dsSrc.Tables["SalPayPlan"]; DataTable table3 = dsSrc.Tables["SalPayRela"]; dao.EntityName = "SalPay"; EntityData entitydata = new EntityData("SalPay"); string[] Params = new string[] { "@ClientCode" }; object[] values = new object[] { ClientCode }; dao.FillEntity(SqlManager.GetSqlStruct("SalPay", "SelectByClient").SqlString, Params, values, entitydata, "SalPay"); if (entitydata.HasRecord()) { dao.DeleteAllRow(entitydata); dao.DeleteEntity(entitydata); } for (int i = 0; i < table.Rows.Count; i++) { DataRow row = entitydata.CurrentTable.NewRow(); DataRow row2 = table.Rows[i]; row["ClientCode"] = ClientCode; row["ProjectCode"] = ProjectCode; row["PayCode"] = row2["account_code"]; row["AccountCode"] = row2["account_code"]; row["PayDate"] = row2["account_date"]; row["PayMoney"] = row2["account_price"]; row["PayType"] = row2["account_type"]; row["Remark"] = row2["remark"]; row["CheckDate"] = row2["check_date"]; row["CheckMan"] = row2["check_man"]; string text = ""; DataRow[] rowArray = table3.Select("account_code = '" + row2["account_code"].ToString() + "'"); if (rowArray.Length > 0) { string text2 = rowArray[0]["plan_code"].ToString(); if (text2 != "") { DataRow[] rowArray2 = table2.Select("pay_plan_code = '" + text2 + "'"); if (rowArray2.Length > 0) { text = rowArray2[0]["contract_code"].ToString(); } } } row["ContractCode"] = text; entitydata.AddNewRecord(row); dao.InsertEntity(entitydata); } data2 = entitydata; } catch (Exception exception) { throw exception; } return(data2); }
private static EntityData ImportSalContractByClient(string ClientCode, string ProjectCode, DataSet dsSrc, StandardEntityDAO dao) { EntityData data2; try { DataTable table = dsSrc.Tables["Contract"]; dao.EntityName = "SalContract"; EntityData entitydata = new EntityData("SalContract"); string[] Params = new string[] { "@ClientCode" }; object[] values = new object[] { ClientCode }; dao.FillEntity(SqlManager.GetSqlStruct("SalContract", "SelectByClient").SqlString, Params, values, entitydata, "SalContract"); if (entitydata.HasRecord()) { dao.DeleteAllRow(entitydata); dao.DeleteEntity(entitydata); } for (int i = 0; i < table.Rows.Count; i++) { DataRow row = entitydata.CurrentTable.NewRow(); DataRow row2 = table.Rows[i]; string contractCode = row2["contract_code"].ToString(); row["ProjectCode"] = ProjectCode; row["ContractCode"] = contractCode; row["ContractID"] = row2["contract_id"]; row["ClientCode"] = row2["client_code"]; row["ClientName"] = row2["client_name"]; row["RoomCode"] = row2["room_code"]; row["ContractDate"] = row2["contract_date"]; row["TotalPrice"] = row2["total_price"]; row["FactPrice"] = row2["fact_price"]; row["UnitPrice"] = row2["unit_price"]; //row["Jiesuan"] = row2["jiesuan"]; // row["BofangCode"] = row2["bofang_code"]; row["ChamberName"] = row2["chamber"]; row["BuildDim"] = row2["build_dim"]; row["RoomDim"] = row2["room_dim"]; row["Room"] = row2["room"]; row["BuildingName"] = row2["build_name"]; //row["JiesuanDate"] = row2["jiesuan_date"]; string suplCodeByName = GetSuplCodeByName(GetSuplNameByContract(row["ContractID"].ToString(), 4), ProjectCode); row["SuplCode"] = suplCodeByName; string roomCode = ProductRule.GetRoomCodeByChamberRoomName(ConvertRule.ToString(row["ChamberName"]), ConvertRule.ToString(row["Room"]), ProjectCode); row["RoomCode"] = roomCode; UpdateRoomSalState(roomCode, contractCode); entitydata.AddNewRecord(row); dao.InsertEntity(entitydata); } data2 = entitydata; } catch (Exception exception) { throw exception; } return(data2); }
public static void DeleteStandard_ConstructProgress(EntityData entity) { try { using (StandardEntityDAO ydao = new StandardEntityDAO("Standard_ConstructProgress")) { ydao.DeleteAllRow(entity); ydao.DeleteEntity(entity); } } catch (Exception exception) { throw exception; } }
public static void DeleteStandard_Supplier(EntityData entity) { try { using (StandardEntityDAO ydao = new StandardEntityDAO("Standard_Supplier")) { ydao.DeleteAllRow(entity); ydao.DeleteEntity(entity); } } catch (Exception exception) { throw exception; } }
public static void DeletePic_Store(EntityData entity) { try { using (StandardEntityDAO ydao = new StandardEntityDAO("PIC_STORE")) { ydao.DeleteAllRow(entity); ydao.DeleteEntity(entity); } } catch (Exception exception) { throw exception; } }
private void ImportSalPay(string[] m_strSub, string ContractCode, string ProjectCode, StandardEntityDAO dao) { try { dao.EntityName = "SalPay"; EntityData entity = new EntityData("SalPay"); string[] os = { "@ContractCode" }; object[] ob = { ContractCode }; dao.FillEntity(SqlManager.GetSqlStruct("SalPay", "SelectByContract").SqlString, os, ob, entity, "SalPay"); if (entity.HasRecord()) { dao.DeleteAllRow(entity); dao.DeleteEntity(entity); } DataRow dr; dr = entity.CurrentTable.NewRow(); dr["ProjectCode"] = ProjectCode; dr["ContractCode"] = ContractCode; dr["ContractID"] = m_strSub[2]; dr["PayCode"] = m_strSub[2]; dr["AccountCode"] = m_strSub[2]; try { dr["PayMoney"] = m_strSub[9]; } catch { dr["PayMoney"] = 0; } entity.AddNewRecord(dr); dao.InsertEntity(entity); entity.Dispose(); } catch (Exception ex) { throw ex; } }
private static EntityData ImportSalPayPlanByClient(string ClientCode, string ProjectCode, DataSet dsSrc, StandardEntityDAO dao) { EntityData data2; try { DataTable table = dsSrc.Tables["SalPayPlan"]; dao.EntityName = "SalPayPlan"; EntityData entitydata = new EntityData("SalPayPlan"); string[] Params = new string[] { "@ClientCode" }; object[] values = new object[] { ClientCode }; dao.FillEntity(SqlManager.GetSqlStruct("SalPayPlan", "SelectByClient").SqlString, Params, values, entitydata, "SalPayPlan"); if (entitydata.HasRecord()) { dao.DeleteAllRow(entitydata); dao.DeleteEntity(entitydata); } for (int i = 0; i < table.Rows.Count; i++) { DataRow row = entitydata.CurrentTable.NewRow(); DataRow row2 = table.Rows[i]; row["PayPlanCode"] = row2["pay_plan_code"]; row["ClientCode"] = ClientCode; row["ProjectCode"] = ProjectCode; row["ContractCode"] = row2["contract_code"]; row["PayMode"] = row2["pay_mode"]; row["Prompt"] = row2["Prompt"]; row["PlanMoney"] = row2["price"]; row["ItemName"] = row2["item_name"]; entitydata.AddNewRecord(row); dao.InsertEntity(entitydata); } data2 = entitydata; } catch (Exception exception) { throw exception; } return(data2); }
protected void btnSave_ServerClick(object sender, System.EventArgs e) { try { string projectCode = Request["ProjectCode"] + ""; if (this.txtFile.PostedFile.FileName == "") { Response.Write(Rms.Web.JavaScript.Alert(true, "请选择文件!")); return; } if (this.txtFile.PostedFile.ContentLength == 0) { Response.Write(Rms.Web.JavaScript.Alert(true, "该文件是空文件!")); return; } if (this.inputSystemGroupPayout.Value == "") { Response.Write(Rms.Web.JavaScript.Alert(true, "请选择付款类型!")); return; } if (this.inputSystemGroupPayment.Value == "") { Response.Write(Rms.Web.JavaScript.Alert(true, "请选择请款类型!")); return; } try { EntityData CBS = DAL.EntityDAO.CBSDAO.GetCBSByProject(projectCode); //检查费用项是否已建立 if (!CBS.HasRecord()) { throw new Exception("未建立费用项,不能导入凭证"); } /*----------------------------记录要导入的凭证号(可能有多个)--------------------------*/ DataTable tbV = new DataTable(); tbV.Columns.Add("VoucherCode"); tbV.Columns.Add("VoucherID"); ArrayList arr = new ArrayList(); StreamReader m_sr = new StreamReader(this.txtFile.PostedFile.InputStream, System.Text.Encoding.Default); // 第一行跳过 m_sr.ReadLine(); string strTemp; while ((strTemp = m_sr.ReadLine()) != null) { arr.Add(strTemp); //记录凭证号 string [] sFields = strTemp.Split(new char[] { ',' }); for (int i = 0; i < sFields.Length; i++) { sFields[i] = sFields[i].Replace("\"", ""); } string VoucherID = "B" + sFields[2]; if (tbV.Select("VoucherID='" + VoucherID + "'").Length == 0) { string VoucherCode = ""; //取系统的凭证号 QueryAgent qa = new Rms.ORMap.QueryAgent(); try { VoucherCode = BLL.ConvertRule.ToString(qa.ExecuteScalar(String.Format("select VoucherCode from Voucher where VoucherID = '{0}' and ProjectCode='{1}'", VoucherID, projectCode))); } finally { qa.Dispose(); } DataRow drNew = tbV.NewRow(); drNew["VoucherCode"] = VoucherCode; drNew["VoucherID"] = VoucherID; tbV.Rows.Add(drNew); } } m_sr.Close(); //删除老的凭证、请款、付款 foreach (DataRow drV in tbV.Rows) { //事务处理 using (StandardEntityDAO dao = new StandardEntityDAO("Voucher")) { dao.BeginTrans(); try { string VoucherCode = drV["VoucherCode"].ToString(); string VoucherID = drV["VoucherID"].ToString(); if (VoucherCode != "") { //删除凭证 dao.EntityName = "Standard_Voucher"; EntityData entityV = DAL.EntityDAO.PaymentDAO.GetStandard_VoucherByCode(VoucherCode); if (entityV.HasRecord()) { dao.DeleteAllRow(entityV); dao.DeleteEntity(entityV); } entityV.Dispose(); } //取系统的请款单号 string PaymentCode = ""; QueryAgent qa = new Rms.ORMap.QueryAgent(); try { PaymentCode = BLL.ConvertRule.ToString(qa.ExecuteScalar(String.Format("select PaymentCode from Payment where PaymentID = '{0}' and ProjectCode='{1}'", VoucherID, projectCode))); } finally { qa.Dispose(); } //删除请款 if (PaymentCode != "") { dao.EntityName = "Standard_Payment"; EntityData entityP = DAL.EntityDAO.PaymentDAO.GetStandard_PaymentByCode(PaymentCode); if (entityP.HasRecord()) { dao.DeleteAllRow(entityP); dao.DeleteEntity(entityP); } entityP.Dispose(); } //取系统的付款单号 string PayoutCode = ""; qa = new Rms.ORMap.QueryAgent(); try { PayoutCode = BLL.ConvertRule.ToString(qa.ExecuteScalar(String.Format("select PayoutCode from Payout where PayoutID = '{0}' and ProjectCode='{1}'", VoucherID, projectCode))); } finally { qa.Dispose(); } //删除付款 if (PayoutCode != "") { dao.EntityName = "Standard_Payout"; EntityData entityP = DAL.EntityDAO.PaymentDAO.GetStandard_PayoutByCode(PayoutCode); if (entityP.HasRecord()) { dao.DeleteAllRow(entityP); dao.DeleteEntity(entityP); } entityP.Dispose(); } dao.CommitTrans(); } catch (Exception ex) { try { //RollBackTrans会报错:此 SqlTransaction 已完成;它再也无法使用 dao.RollBackTrans(); } catch { } throw ex; } } } EntityData voucher = new EntityData("Standard_Voucher"); EntityData payout = new EntityData("Standard_Payout"); EntityData payment = new EntityData("Standard_Payment"); voucher.Tables["Voucher"].Columns.Add("SupplierCode"); voucher.Tables["Voucher"].Columns.Add("SupplierName"); long LastVoucherCode = BLL.ConvertRule.ToLong(BLL.PaymentRule.GetNextVoucherCode()) - 1; foreach (string val in arr) { string [] sFields = val.Split(new char[] { ',' }); for (int i = 0; i < sFields.Length; i++) { sFields[i] = sFields[i].Replace("\"", ""); } string std = sFields[0]; string type = sFields[1]; if ((type != "2") && (type != "4") && (type != "5")) { throw new Exception("只能导入付出凭证"); } // if ( type.Length == 1 ) // type = "0" + type; string voucherID = "B" + sFields[2]; // 凭证表 string voucherCode = ""; DataRow drV = null; voucher.SetCurrentTable("Voucher"); DataRow[] drVs = voucher.CurrentTable.Select(String.Format("VoucherID='{0}'", voucherID)); if (drVs.Length > 0) { drV = drVs[0]; voucherCode = (string)drV["VoucherCode"]; } else { drV = voucher.GetNewRecord(); LastVoucherCode++; voucherCode = LastVoucherCode.ToString(); drV["VoucherCode"] = voucherCode; drV["ProjectCode"] = projectCode; drV["VoucherID"] = voucherID; drV["VoucherType"] = type; drV["MakeDate"] = std; drV["Status"] = 2; drV["Accountant"] = user.UserCode; drV["AccountDate"] = std; drV["IsExported"] = 1; drV["ExportDate"] = DateTime.Now; drV["CheckPerson"] = user.UserCode; drV["CheckDate"] = std; voucher.AddNewRecord(drV); } //用友的供应商代码 string UFSupplierCode = sFields[18]; string SupplierCode = ""; if (UFSupplierCode != "") { //按用友代码取系统代码 QueryAgent qa = new Rms.ORMap.QueryAgent(); try { SupplierCode = BLL.ConvertRule.ToString(qa.ExecuteScalar(String.Format("select SupplierCode from Supplier where U8Code = '{0}'", UFSupplierCode))); } finally { qa.Dispose(); } } drV["SupplierCode"] = SupplierCode; //供应商名称 string supplierName = ""; if (sFields.Length > 66) { supplierName = sFields[65]; } drV["SupplierName"] = supplierName; //凭证分录 begin----------------------------------------------------- voucher.SetCurrentTable("VoucherDetail"); DataRow drVD = voucher.GetNewRecord(); drVD["VoucherDetailCode"] = DAL.EntityDAO.SystemManageDAO.GetNewSysCode("VoucherDetailCode"); drVD["VoucherCode"] = voucherCode; drVD["Summary"] = sFields[4]; drVD["SubjectCode"] = sFields[5]; if (Rms.Check.StringCheck.IsNumber(sFields[6])) { drVD["DebitMoney"] = sFields[6]; } else { drVD["DebitMoney"] = decimal.Zero; } if (Rms.Check.StringCheck.IsNumber(sFields[7])) { drVD["CrebitMoney"] = sFields[7]; } else { drVD["CrebitMoney"] = decimal.Zero; } drVD["BillNo"] = sFields[13]; drVD["ProjectCode"] = projectCode; drVD["RelaType"] = "付款"; //用友的项目代码,即系统的项目代码 drVD["UFProjectCode"] = sFields[20]; //供应商代码 drVD["CustCode"] = SupplierCode; voucher.AddNewRecord(drVD); //凭证分录 end----------------------------------------------------- } m_sr.Close(); // 补付款和请款 voucher.SetCurrentTable("Voucher"); foreach (DataRow drV in voucher.Tables["Voucher"].Rows) { string voucherCode = (string)drV["VoucherCode"]; string voucherID = (string)drV["VoucherID"]; // 付款 payout.SetCurrentTable("Payout"); DataRow drP = payout.GetNewRecord(); string payoutCode = DAL.EntityDAO.SystemManageDAO.GetNewSysCode("PayoutCode"); drP["PayoutCode"] = payoutCode; drP["ProjectCode"] = projectCode; drP["PayoutDate"] = drV["MakeDate"]; //现金的科目以“101”开头 if (voucher.Tables["VoucherDetail"].Select(String.Format(" VoucherCode='{0}' and SubjectCode like '101' ", voucherCode)).Length > 0) { drP["PaymentType"] = "现金"; } else { drP["PaymentType"] = "支票"; } drP["Payer"] = "补单"; drP["SupplyCode"] = drV["SupplierCode"]; drP["SupplyName"] = drV["SupplierName"]; drP["PayoutID"] = voucherID; DataRow[] drsCre = voucher.Tables["VoucherDetail"].Select(String.Format(" VoucherCode='{0}' and CrebitMoney>0 ", voucherCode)); decimal payoutMoney = BLL.MathRule.SumColumn(drsCre, "CrebitMoney"); drP["Money"] = payoutMoney; // 凭证的总金额项 drV["TotalMoney"] = payoutMoney; if (drsCre.Length > 0) { drP["SubjectCode"] = drsCre[0]["SubjectCode"]; } drP["Status"] = 1; drP["CheckPerson"] = user.UserCode; drP["CheckDate"] = drV["MakeDate"]; drP["GroupCode"] = this.inputSystemGroupPayout.Value; drP["IsApportioned"] = 0; payout.AddNewRecord(drP); // 请款 payment.SetCurrentTable("Payment"); DataRow drPM = payment.GetNewRecord(); string paymentCode = DAL.EntityDAO.SystemManageDAO.GetNewSysCode("PaymentCode"); drPM["PaymentCode"] = paymentCode; drPM["ProjectCode"] = projectCode; drPM["PaymentID"] = voucherID; drPM["VoucherID"] = voucherID; drPM["ApplyPerson"] = user.UserCode; drPM["ApplyDate"] = drV["MakeDate"]; drPM["Payer"] = "补单"; drPM["PayDate"] = drV["MakeDate"]; drPM["Money"] = payoutMoney; drPM["CheckPerson"] = user.UserCode; drPM["CheckDate"] = drV["MakeDate"]; drPM["IsContract"] = 0; drPM["Status"] = 2; drPM["IsApportion"] = 0; drPM["SupplyCode"] = drV["SupplierCode"]; drPM["SupplyName"] = drV["SupplierName"]; drPM["GroupCode"] = this.inputSystemGroupPayment.Value; payment.AddNewRecord(drPM); // 付款请款分项 payout.SetCurrentTable("PayoutItem"); payment.SetCurrentTable("PaymentItem"); foreach (DataRow drVD in voucher.Tables["VoucherDetail"].Select(String.Format(" VoucherCode='{0}' and DebitMoney <> 0 ", voucherCode))) { string subjectCode = BLL.ConvertRule.ToString(drVD["SubjectCode"]); DataRow drPMItem = payment.GetNewRecord(); string paymentItemCode = DAL.EntityDAO.SystemManageDAO.GetNewSysCode("PaymentItemCode"); drPMItem["PaymentItemCode"] = paymentItemCode; drPMItem["PaymentCode"] = paymentCode; drPMItem["ItemMoney"] = drVD["DebitMoney"]; drPMItem["CostCode"] = GetCostCode(subjectCode, CBS); drPMItem["Summary"] = drVD["Summary"]; drPMItem["AlloType"] = "P"; payment.AddNewRecord(drPMItem); DataRow drPD = payout.GetNewRecord(); drPD["PayoutItemCode"] = DAL.EntityDAO.SystemManageDAO.GetNewSysCode("PayoutItemCode"); drPD["PayoutCode"] = payoutCode; drPD["PayoutMoney"] = drVD["DebitMoney"]; drPD["SubjectCode"] = subjectCode; drPD["Remark"] = drVD["Summary"]; drPD["AlloType"] = "P"; drPD["IsManualAlloc"] = 0; drPD["PaymentItemCode"] = paymentItemCode; payout.AddNewRecord(drPD); // 凭证的相关编码 drVD["RelaCode"] = payoutCode; } } DAL.EntityDAO.PaymentDAO.SubmitAllStandard_Payout(payout); DAL.EntityDAO.PaymentDAO.SubmitAllStandard_Voucher(voucher); DAL.EntityDAO.PaymentDAO.SubmitAllStandard_Payment(payment); voucher.Dispose(); payout.Dispose(); payment.Dispose(); CBS.Dispose(); Response.Write(JavaScript.ScriptStart); Response.Write(JavaScript.Alert(false, "导入成功 !")); Response.Write(JavaScript.OpenerReload(false)); Response.Write("window.close();"); Response.Write(JavaScript.ScriptEnd); } catch (Exception ex) { throw ex; } } catch (Exception ex) { ApplicationLog.WriteLog(this.ToString(), ex, ""); Response.Write(JavaScript.Alert(true, "导入失败:" + ex.Message)); } }
public static void DeleteSystemGroup(string GroupCode) { Exception exception; try { if (GroupCode != "") { string message = CheckDeleteSystemGroup(GroupCode); if (message != "") { throw new Exception(message); } EntityData systemGroupByCode = SystemManageDAO.GetSystemGroupByCode(GroupCode); if (systemGroupByCode.HasRecord()) { string keyvalues; string parentFullID = systemGroupByCode.GetString("FullID"); DataTable table = new DataTable(); table.Columns.Add("AccessRangeCode"); EntityData systemGroupIncludeAllChildByParentFullID = SystemManageDAO.GetSystemGroupIncludeAllChildByParentFullID(parentFullID); foreach (DataRow row in systemGroupIncludeAllChildByParentFullID.CurrentTable.Rows) { EntityData accessRangeByGroupCode = ResourceDAO.GetAccessRangeByGroupCode(row["GroupCode"].ToString()); foreach (DataRow row2 in accessRangeByGroupCode.CurrentTable.Rows) { keyvalues = row2["AccessRangeCode"].ToString(); DataRow row3 = table.NewRow(); row3["AccessRangeCode"] = keyvalues; table.Rows.Add(row3); } accessRangeByGroupCode.Dispose(); } using (StandardEntityDAO ydao = new StandardEntityDAO("SystemGroup")) { ydao.BeginTrans(); try { foreach (DataRow row3 in table.Rows) { keyvalues = row3["AccessRangeCode"].ToString(); ydao.EntityName = "AccessRange"; EntityData entitydata = new EntityData("AccessRange"); entitydata = ydao.SelectbyPrimaryKey(keyvalues); ydao.DeleteAllRow(entitydata); ydao.DeleteEntity(entitydata); entitydata.Dispose(); } foreach (DataRow row3 in systemGroupIncludeAllChildByParentFullID.CurrentTable.Rows) { string text3 = row3["GroupCode"].ToString(); ydao.EntityName = "SystemGroup"; EntityData data5 = new EntityData("SystemGroup"); data5 = ydao.SelectbyPrimaryKey(text3); ydao.DeleteAllRow(data5); ydao.DeleteEntity(data5); data5.Dispose(); } ydao.CommitTrans(); } catch (Exception exception1) { exception = exception1; try { ydao.RollBackTrans(); } catch { } throw exception; } } systemGroupIncludeAllChildByParentFullID.Dispose(); } systemGroupByCode.Dispose(); } } catch (Exception exception2) { exception = exception2; throw exception; } }
/// <summary> /// 清空 /// </summary> private static void DeleteSingle(string ProjectCode, string VoucherID) { try { string VoucherCode = ""; //取系统的凭证号 QueryAgent qa = new QueryAgent(); try { VoucherCode = BLL.ConvertRule.ToString(qa.ExecuteScalar(String.Format("select VoucherCode from Voucher where VoucherID = '{0}' and ProjectCode='{1}'", VoucherID, ProjectCode))); } finally { qa.Dispose(); } //删除老的凭证、请款、付款 //事务处理 using (StandardEntityDAO dao = new StandardEntityDAO("Voucher")) { dao.BeginTrans(); try { if (VoucherCode != "") { //删除凭证 dao.EntityName = "Standard_Voucher"; EntityData entityV = DAL.EntityDAO.PaymentDAO.GetStandard_VoucherByCode(VoucherCode); if (entityV.HasRecord()) { dao.DeleteAllRow(entityV); dao.DeleteEntity(entityV); } entityV.Dispose(); } //取系统的请款单号 string PaymentCode = ""; qa = new Rms.ORMap.QueryAgent(); try { PaymentCode = BLL.ConvertRule.ToString(qa.ExecuteScalar(String.Format("select PaymentCode from Payment where PaymentID = '{0}' and ProjectCode='{1}'", VoucherID, ProjectCode))); } finally { qa.Dispose(); } //删除请款 if (PaymentCode != "") { dao.EntityName = "Standard_Payment"; EntityData entityP = DAL.EntityDAO.PaymentDAO.GetStandard_PaymentByCode(PaymentCode); if (entityP.HasRecord()) { dao.DeleteAllRow(entityP); dao.DeleteEntity(entityP); } entityP.Dispose(); } //取系统的付款单号 string PayoutCode = ""; qa = new Rms.ORMap.QueryAgent(); try { PayoutCode = BLL.ConvertRule.ToString(qa.ExecuteScalar(String.Format("select PayoutCode from Payout where PayoutID = '{0}' and ProjectCode='{1}'", VoucherID, ProjectCode))); } finally { qa.Dispose(); } //删除付款 if (PayoutCode != "") { dao.EntityName = "Standard_Payout"; EntityData entityP = DAL.EntityDAO.PaymentDAO.GetStandard_PayoutByCode(PayoutCode); if (entityP.HasRecord()) { dao.DeleteAllRow(entityP); dao.DeleteEntity(entityP); } entityP.Dispose(); } dao.CommitTrans(); } catch (Exception ex) { try { //RollBackTrans会报错:此 SqlTransaction 已完成;它再也无法使用 dao.RollBackTrans(); } catch { } throw ex; } } } catch (Exception ex) { throw ex; } }
public static void PBSTypeCopyByProject(string srcProjectCode, string dstProjectCode) { Exception exception; try { using (StandardEntityDAO ydao = new StandardEntityDAO("PBSType")) { ydao.BeginTrans(); try { EntityData entitydata = new EntityData("PBSType"); ydao.FillEntity(SqlManager.GetSqlStruct("PBSType", "SelectByProjectCode").SqlString, "@ProjectCode", dstProjectCode, entitydata, "PBSType"); ydao.DeleteAllRow(entitydata); ydao.DeleteEntity(entitydata); DataTable table = new DataTable(); table.Columns.Add("OldPBSTypeCode", typeof(string)); table.Columns.Add("NewPBSTypeCode", typeof(string)); EntityData data2 = new EntityData("PBSType"); ydao.FillEntity(SqlManager.GetSqlStruct("PBSType", "SelectByProjectCode").SqlString, "@ProjectCode", srcProjectCode, data2, "PBSType"); int num = 1; for (DataRow[] rowArray = data2.CurrentTable.Select("deep=" + num.ToString()); rowArray.Length > 0; rowArray = data2.CurrentTable.Select("deep=" + num.ToString())) { foreach (DataRow row in rowArray) { DataRow row2 = entitydata.CurrentTable.NewRow(); string newSysCode = SystemManageDAO.GetNewSysCode("PBSTypeCode"); row2["PBSTypeCode"] = newSysCode; row2["ProjectCode"] = dstProjectCode; row2["PBSTypeName"] = ConvertRule.ToString(row["PBSTypeName"]); row2["Description"] = ConvertRule.ToString(row["Description"]); row2["Deep"] = ConvertRule.ToInt(row["Deep"]); row2["SortID"] = ConvertRule.ToInt(row["SortID"]); DataRow row3 = table.NewRow(); row3["OldPBSTypeCode"] = ConvertRule.ToString(row["PBSTypeCode"]); row3["NewPBSTypeCode"] = newSysCode; table.Rows.Add(row3); string text2 = ConvertRule.ToString(row["ParentCode"]); if (text2 != "") { DataRow[] rowArray2 = table.Select("OldPBSTypeCode='" + text2 + "'"); if (rowArray2.Length > 0) { text2 = ConvertRule.ToString(rowArray2[0]["NewPBSTypeCode"]); } } string text3 = ""; if (text2 != "") { DataRow[] rowArray3 = entitydata.CurrentTable.Select("PBSTypeCode='" + text2 + "'"); if (rowArray3.Length > 0) { text3 = ConvertRule.ToString(rowArray3[0]["FullID"]); } } string text4 = newSysCode; if (text3 != "") { text4 = text3 + "-" + text4; } row2["ParentCode"] = text2; row2["FullID"] = text4; entitydata.CurrentTable.Rows.Add(row2); } num++; } ydao.InsertEntity(entitydata); ydao.CommitTrans(); data2.Dispose(); entitydata.Dispose(); } catch (Exception exception1) { exception = exception1; try { ydao.RollBackTrans(); } catch { } throw exception; } } } catch (Exception exception2) { exception = exception2; throw exception; } }