public override void CellChanged(UFIDA.U8.UAP.UI.Runtime.Common.CellChangeEventArgs para, BusinessProxy businessObject, VoucherProxy voucherObject) { base.CellChanged(para, businessObject, voucherObject); if (para.ColumnName == "cName") { } }
public override IButtonEventHandler GetButtonEventHandler(VoucherButtonArgs ButtonArgs, VoucherProxy voucherObject) { IButtonEventHandler buttonEventHandler = base.GetButtonEventHandler(ButtonArgs, voucherObject); IButtonEventHandler result; if (buttonEventHandler == null) { if (ButtonArgs.ButtonKey == "btnSWRefConsume") { string value = voucherObject.Businesses["12f73210-161b-4d45-94a0-6589e1ec7ae2"].Cells["ExpenserID"].Value; if (string.IsNullOrEmpty(value)) { MessageBox.Show("请先选择表头报销人!"); result = null; return result; } result = new NEExposHandler_RefConsum(value); return result; } else if (ButtonArgs.ButtonKey == "btnSWImportDetail") { result = new NEExposHandler_ImportDetail(); return result; } } result = buttonEventHandler; return result; }
public override void CellChanged(UFIDA.U8.UAP.UI.Runtime.Common.CellChangeEventArgs para, BusinessProxy businessObject, VoucherProxy voucherObject) { base.CellChanged(para, businessObject, voucherObject); if (para.ColumnName == "cBudgetItemID") { Business business = voucherObject.Businesses["27d9db0f-1099-4e02-a070-45fa6b11db89"]; string currentPKValue = business.PrimaryKey; if (!string.IsNullOrEmpty(currentPKValue)) { if (para.NewHiddenValue == null && string.IsNullOrEmpty(para.NewHiddenValue.ToString())) { business.Rows[currentPKValue].Cells["cPayToken"].Value = (""); } else { VoucherSrv voucherSrv = new VoucherSrv(); string text = "select cToken from BG_V_ItemToken where cItemCode='" + para.NewHiddenValue.ToString() + "'"; DataSet dataSet = voucherSrv.ExcuteSqlInData(text); if (dataSet != null && dataSet.Tables != null && dataSet.Tables.Count > 0 && dataSet.Tables[0].Rows.Count > 0) { DataRow dataRow = dataSet.Tables[0].Rows[0]; business.Rows[currentPKValue].Cells["cPayToken"].Value = dataRow["cToken"] == null ? "" : dataRow["cToken"].ToString(); } } } } }
public string Excute(VoucherProxy ReceiptObject, string PreExcuteResult) { this.voucherObject = ReceiptObject; RefConsume refConsume = new RefConsume(ReceiptObject, this.CurUserID); refConsume.Closed += (new EventHandler(this.rc_Closed)); refConsume.Show(); return this.MakeExcuteState(true, ""); }
public override IButtonEventHandler GetButtonEventHandler(VoucherButtonArgs ButtonArgs, VoucherProxy voucherObject) { IButtonEventHandler result; if (ButtonArgs.ButtonKey == "btnSWImport") { result = new ConsumHandler_Import(); } else { result = null; } return result; }
public override IButtonEventHandler GetButtonEventHandler(VoucherButtonArgs ButtonArgs, VoucherProxy voucherObject) { IButtonEventHandler result; if (ButtonArgs.ButtonKey == "btnSWPay") { result = new SWCPHandler_CreatePay(); } else if (ButtonArgs.ButtonKey == "btnSWExport") { result = new SWCPHandler_Export(); } else { result = null; } return result; }
public RefConsume(VoucherProxy _voucherObject, string CurUserID) { this.voucherObject = _voucherObject; this.InitializeComponent(); RadGridView radGridView = (RadGridView)base.FindName("BHRadGrid"); radGridView.Columns.Clear(); this.gridDataSource = new List<GridCol_RefCon>(); VoucherSrv voucherSrv = new VoucherSrv(); string text = "select cs.cCardNO,cs.fConsumeAmount,cs.dConsumeDate,cs.subPrimaryKey,p.cPersonCode,p.cPersonName,cs.cConCusName,cs.cUse,cs.cBillNO from SWGW_Consumes cs join SWGW_Consume c on cs.foreignKey=c.mainPrimaryKey left join Person p on cs.cBXCode=p.cPersonCode where iIsExpensedB=0 and c.iverifystate=2"; text = text + " and cs.cBXCode='" + CurUserID + "'"; DataSet dataSet = voucherSrv.ExcuteSqlInData(text); if (dataSet != null && dataSet.Tables != null && dataSet.Tables.Count > 0) { DataTable dataTable = dataSet.Tables[0]; if (dataTable.Rows.Count > 0) { using (IEnumerator<DataRow> enumerator = dataTable.Rows.GetEnumerator()) { while (enumerator.MoveNext()) { DataRow current = enumerator.Current; double 消费金额 = 0.0; double.TryParse(current["fConsumeAmount"], out 消费金额); this.gridDataSource.Add(new GridCol_RefCon { 选择 = true, 公务卡号 = current["cCardNO"], 姓名 = current["cPersonName"], 消费日期 = Convert.ToDateTime(current["dConsumeDate"]).ToString("yyyy-MM-dd"), 消费金额 = 消费金额, ID = current["subPrimaryKey"], cPersonCode = current["cPersonCode"], 商户名称 = current["cConCusName"], 用途 = current["cUse"], 支票号 = current["cBillNO"] }); } } radGridView.ItemsSource = (this.gridDataSource); } } }
public string Excuted(VoucherProxy ReceiptObject, string PreExcuteResult) { Business business = ReceiptObject.Businesses["27d9db0f-1099-4e02-a070-45fa6b11db89"]; business.Clear(); VoucherSrv voucherSrv = new VoucherSrv(); string text = "select cs.cCardNO,cs.cBXCode,cs.cBillNO,cs.cConCusName,cs.cUse,ns.ExpenseMoney,n.ExpenseDate,p.cPersonName,ns.ID ,bg.cItemCode,bg.cItemName,bgt.cToken from NE_ExpenseVouch_Sub ns join NE_ExpenVouch n on n.ID=ns.ExpenseVouchID join SWGW_Consumes cs on cs.subPrimaryKey=ns.cNeDefine11 join Person p on cs.cBXCode=p.cPersonCode left join BG_V_CtrlItem bg on bg.cItemCode=ns.BudgetItemID left join BG_V_ItemToken bgt on bg.cItemCode=bgt.cItemCode where n.IVerifyState=2 and isnull(ns.cNeDefine12,'0')<>'1' and len(isnull(ns.cNeDefine11,''))>35"; DataSet dataSet = voucherSrv.ExcuteSqlInData(text); string result; if (dataSet == null || dataSet.Tables == null || dataSet.Tables.Count <= 0 || dataSet.Tables[0].Rows.Count <= 0) { result = this.MakeExcuteState(true, ""); } else { DataTable dataTable = dataSet.Tables[0]; using (IEnumerator<DataRow> enumerator = dataTable.Rows.GetEnumerator()) { while (enumerator.MoveNext()) { DataRow current = enumerator.Current; string text2 = business.AddRow(-1); business.Rows[text2].Cells["cCardNO"].Value = (current["cCardNO"].ToString()); business.FireCellChangeEvent(text2, "cBXCode", null, current["cBXCode"].ToString(), current["cPersonName"].ToString()); business.Rows[text2].Cells["dPayDate"].Value = (current["ExpenseDate"].ToString()); business.Rows[text2].Cells["fPayAmount"].Value = (current["ExpenseMoney"].ToString()); business.Rows[text2].Cells["cBillNO"].Value = (current["cBillNO"].ToString()); business.Rows[text2].Cells["cConCusName"].Value = (current["cConCusName"].ToString()); business.Rows[text2].Cells["cUse"].Value = (current["cUse"].ToString()); business.Rows[text2].Cells["cExpenseDetailID"].Value = (current["ID"].ToString()); if (current[("cItemCode")] != null && !string.IsNullOrEmpty(current["cItemCode"].ToString())) { business.FireCellChangeEvent(text2, "cBudgetItemID", null, current["cItemCode"].ToString(), current["cItemName"].ToString()); } business.Rows[text2].Cells["cPayToken"].Value = ((current["cToken"] == null) ? "" : current["cToken"].ToString()); } } result = this.MakeExcuteState(true, ""); } return result; }
public string Excuted(VoucherProxy ReceiptObject, string PreExcuteResult) { Business business = ReceiptObject.Businesses["439d4404-48e9-4e43-af8a-5d5534b1189c"]; Business business2 = ReceiptObject.Businesses["27d9db0f-1099-4e02-a070-45fa6b11db89"]; if (business.Rows[0].Cells["IVerifyState"].Value != "2") { throw new Exception("请审核通过后再导出!"); } StringBuilder stringBuilder = new StringBuilder("<?xml version='1.0' encoding='utf-8'?><Root>"); int count = business2.Rows.Count; for (int i = 0; i < count; i++) { BusinessRow businessRow = business2.Rows[i]; stringBuilder.AppendLine("<cExpenseDetailID Value='" + businessRow.Cells["cExpenseDetailID"].Value + "'/>"); } stringBuilder.AppendLine("</Root>"); SaveFileDialog saveFileDialog = new SaveFileDialog(); saveFileDialog.Filter = "xml 文件 | *.xml"; saveFileDialog.DefaultExt = ("xml"); saveFileDialog.DefaultFileName = (DateTime.Now.ToString("yyyy_MM_dd_HH_mm_ss") + ".xml"); bool? flag = saveFileDialog.ShowDialog(); string result; if (!flag.GetValueOrDefault() || !flag.HasValue) { result = this.MakeExcuteState(true, ""); } else { Stream stream = saveFileDialog.OpenFile(); StreamWriter streamWriter = new StreamWriter(stream); streamWriter.Write(stringBuilder.ToString()); streamWriter.Flush(); streamWriter.Close(); result = this.MakeExcuteState(true, ""); } return result; }
public string Excute(VoucherProxy ReceiptObject, string PreExcuteResult) { Business bodys = ReceiptObject.Businesses["a701a36d-ec4f-43c9-b95a-ef77d7600f57"]; Business head = ReceiptObject.Businesses["12f73210-161b-4d45-94a0-6589e1ec7ae2"]; //voucherObject.Businesses["12f73210-161b-4d45-94a0-6589e1ec7ae2"].Cells["OperationTypeCode"].Value == "LWOCH" string operatorType = head.Cells["OperationTypeCode"].Value; Dictionary<string, string> dict = new Dictionary<string, string>(); //dict.Add("LWTCH01", "0146"); //F_35 //dict.Add("LWTCH02", "0126");//F_36 //dict.Add("LWTCH03", "0046");//F_37 //dict.Add("LWTCH04", "0005");//F_38 //dict.Add("LWTCH05", "0047");//F_39 //dict.Add("LWSTD", "0129");//F_76 //dict.Add("LWOCH", "0130");// dict.Add("L", "0146"); //F_35 dict.Add("W", "0126");//F_36 dict.Add("T", "0046");//F_37 dict.Add("C", "0005");//F_38 dict.Add("H", "0047");//F_39 dict.Add("S", "0129");//F_76 dict.Add("O", "0130");// String defalutExpItemCode = null; if (dict.ContainsKey(operatorType)) defalutExpItemCode = dict[operatorType]; //if (head.Rows[0].RowData["ItemID"] == null) //{ // throw new Exception("请先录入项目!"); //} //if (head.Rows[0].RowData["ItemID"].ToString() != "0126") //{ // throw new Exception("只有项目是【工资项目】支持导入!"); //} OpenFileDialog openFileDialog = new OpenFileDialog(); openFileDialog.Filter = ("Excel (*.xls)|*.xls"); bool? flag = openFileDialog.ShowDialog(); string result; if (!flag.GetValueOrDefault() || !flag.HasValue) { result = this.MakeExcuteState(true, ""); } else { FileStream fileStream = openFileDialog.File.OpenRead(); Workbook workbook = Workbook.Open(fileStream); Worksheet worksheet = workbook.Worksheets[0]; int num = 3; if (worksheet.Cells.LastRowIndex < num) //从0开始 { result = this.MakeExcuteState(true, ""); } else { bodys.Clear(); float num2 = 0f; VoucherSrv srv = new VoucherSrv(); for (int i = num; i <= worksheet.Cells.LastRowIndex; i++) { string stringValue_bh = worksheet.Cells[i, 0].StringValue_bh; string stringValue_bh2 = worksheet.Cells[i, 1].StringValue_bh; string stringValue_bh3 = worksheet.Cells[i, 2].StringValue_bh; string stringValue_bh4 = worksheet.Cells[i, 3].StringValue_bh; string stringValue_bh5 = worksheet.Cells[i, 4].StringValue_bh; if (string.IsNullOrEmpty(stringValue_bh5)) stringValue_bh5 = worksheet.Cells[i, 4].StringValue; string stringValue_bh6 = worksheet.Cells[i, 5].StringValue_bh; string stringValue_bh7 = worksheet.Cells[i, 6].StringValue_bh; string stringValue_bh8 = worksheet.Cells[i, 7].StringValue_bh; string stringValue_bh9 = worksheet.Cells[i, 8].StringValue_bh; string stringValue_bh10 = worksheet.Cells[i, 9].StringValue_bh; string stringValue_bh11 = worksheet.Cells[i, 10].StringValue_bh; string rowpk = bodys.AddRow(-1); if (defalutExpItemCode != null) { stringValue_bh6 = defalutExpItemCode; stringValue_bh7 = null; } if (!string.IsNullOrEmpty(stringValue_bh8) && !string.IsNullOrEmpty(stringValue_bh9)) importPsn(srv, stringValue_bh8, stringValue_bh9, stringValue_bh10, stringValue_bh11, "北京", "北京"); this.checkField_person(srv, i, stringValue_bh3, stringValue_bh4, "报销人", "Person", "cPersonCode", "cPersonName", bodys, rowpk, stringValue_bh); if (!string.IsNullOrEmpty(stringValue_bh)) { this.checkField(srv, i, stringValue_bh, ref stringValue_bh2, "部门", "Department", "cDepCode", "cDepName"); } this.checkField(srv, i, stringValue_bh6, ref stringValue_bh7, "费用项目", "ExpenseItem", "cExpCode", "cExpName"); float num3 = 0f; if (!float.TryParse(stringValue_bh5.Replace(",", ""), out num3)) { throw new Exception("excel文件中第" + i.ToString() + "行的金额不是数字格式!"); } if ((double)num3 <= 0.01) { throw new Exception("金额不能为0!"); } if (!string.IsNullOrEmpty(stringValue_bh)) { bodys.FireCellChangeEvent(rowpk, "DeptID", null, stringValue_bh, stringValue_bh2); } bodys.FireCellChangeEvent(rowpk, "CostItemID", null, stringValue_bh6, stringValue_bh7); bodys.Rows[rowpk].Cells["ExpenseMoney"].Value = (num3.ToString()); bodys.Rows[rowpk].Cells["LocalMoney"].Value = (num3.ToString()); bodys.Rows[rowpk].Cells["cNeDefine13"].Value = stringValue_bh8; bodys.Rows[rowpk].Cells["cNeDefine12"].Value = stringValue_bh9; num2 += num3; } head.Rows[0].Cells["ExpenseMoney"].Value = (num2.ToString()); head.Rows[0].Cells["LocalMoney"].Value = (num2.ToString()); result = this.MakeExcuteState(true, ""); } } return result; }
public string Excuted(VoucherProxy ReceiptObject, string PreExcuteResult) { OpenFileDialog openFileDialog = new OpenFileDialog(); openFileDialog.Filter = ("Excel (*.xls)|*.xls"); bool? flag = openFileDialog.ShowDialog(); string result; if (!flag.GetValueOrDefault() || !flag.HasValue) { result = this.MakeExcuteState(true, ""); } else { FileStream fileStream = openFileDialog.File.OpenRead(); Workbook workbook = Workbook.Open(fileStream); Worksheet worksheet = workbook.Worksheets[0]; int num = 3; if (worksheet.Cells.LastRowIndex <= num) { result = this.MakeExcuteState(true, ""); } else { Business business = ReceiptObject.Businesses["37291ff3-92b2-4009-831c-8f3b629906ec"]; business.Clear(); VoucherSrv srv = new VoucherSrv(); for (int i = num; i <= worksheet.Cells.LastRowIndex; i++) { string stringValue_bh = worksheet.Cells[i, 4].StringValue_bh; string stringValue_bh2 = worksheet.Cells[i, 6].StringValue_bh; string stringValue_bh3 = worksheet.Cells[i, 7].StringValue_bh; string stringValue_bh4 = worksheet.Cells[i, 8].StringValue_bh; string stringValue_bh5 = worksheet.Cells[i, 10].StringValue_bh; string stringValue_bh6 = worksheet.Cells[i, 19].StringValue_bh; string stringValue_bh7 = worksheet.Cells[i, 10].StringValue_bh; string stringValue_bh8 = worksheet.Cells[i, 18].StringValue_bh; string stringValue_bh9 = worksheet.Cells[i, 5].StringValue_bh; string text = business.AddRow(-1); business.Rows[text].Cells["cCardNO"].Value = (stringValue_bh); string value = string.Concat(new string[] { stringValue_bh2.Substring(0, 4), "-", stringValue_bh2.Substring(4, 2), "-", stringValue_bh2.Substring(6, 2), " ", stringValue_bh3.Substring(0, 2), ":", stringValue_bh3.Substring(2, 2), ":", stringValue_bh3.Substring(4, 2) }); business.Rows[text].Cells["dConsumeDate"].Value = (value); business.Rows[text].Cells["fConsumeAmount"].Value = (stringValue_bh4); string text2; string text3; this.GetNONameByBankAccount(srv, stringValue_bh, out text2, out text3); if (string.IsNullOrEmpty(text2)) { throw new Exception("根据消费卡号【" + stringValue_bh + "】没有找到人员,请确认!"); } if (stringValue_bh9 != text3) { throw new Exception("根据消费卡号【" + stringValue_bh + "】的持有人和U8系统中持有人不一致,请确认!"); } business.Rows[text].Cells["cBXCode"].Value = (text2); business.Rows[text].Cells["cName"].Value = (text3); business.Rows[text].Cells["cConCusName"].Value = (stringValue_bh7); business.Rows[text].Cells["cUse"].Value = (stringValue_bh8); business.Rows[text].Cells["cBillNO"].Value = (stringValue_bh6); } result = this.MakeExcuteState(true, ""); } } return result; }
public override void CellDoubleClick(CellDoubleClickEventArgs para, BusinessProxy businessObject, VoucherProxy voucherObject) { businessObject.Rows[para.RowKey].Cells[para.ColumnName].Value = "1111"; //businessObject.SetCellsStyle() //businessObject.Cells[para.ColumnName].Value = "CellDoubleClick"; //voucherObject.RefreshView(); }
public override bool ReferOpening(ReferOpenEventArgs para, BusinessProxy businessObject, VoucherProxy voucherObject) { if (para.Column.ColumnName == "cDepCode") //部门参照 { //设置部门参照过滤条件 para.RefService.FilterSQL = "cDepCode='01'"; //cDepCode是部门物理表中的物理字段名 } //else if (para.Column.ColumnName == "cCusCode") //客户参照 //{ // //设置客户参照过滤条件 // para.RefService.FilterSQL = "cCusCode='000'"; //cCusCode是客户物理表中的物理字段名 //} return(true); }
private void CalcBody_ReCalcBXAmount(UFIDA.U8.UAP.UI.Runtime.Common.CellChangeEventArgs para, BusinessProxy businessObject, VoucherProxy voucherObject) { string value = businessObject.Cells["cNeDefine11"].Value; if (string.IsNullOrEmpty(value)) return; string newValue = para.NewValue; if (newValue != "") { double num = 0.0; double.TryParse(newValue, out num); if (num > 0.0) { string value2 = businessObject.Cells["cNeDefine21"].Value; double num2 = 0.0; double.TryParse(value2, out num2); if (num > num2) { businessObject.Cells["ExpenseMoney"].Value = (value2); businessObject.Cells["LocalMoney"].Value = (value2); this.CalcHead_Money(voucherObject); } } } }
public virtual void CellChanged(CellChangeEventArgs para, BusinessProxy businessObject, VoucherProxy voucherObject) { //foreach (var item in rows) //{ //var rows = businessObject.Rows.Values.OrderBy(o => o.Cells["uapruntime_rowno"].Value); //} //if (businessObject.Name == "主表" && para.ColumnName == "cNo") //{ // businessObject.Rows[0].Cells["cMemo"].Value = businessObject.Rows[0].Cells["cNo"].Value; //} }
/// <summary> /// 按钮事件执行前 /// </summary> /// <param name="ReceiptObject"></param> /// <returns></returns> public string Excuting(VoucherProxy ReceiptObject) { // return string.Empty; //返回空字符换 继续执行Excute return("<result><system result=\"true\" errinfo=\"" + "" + "\"/></result>"); //返回true 继续执行Excute //return "<result><system result=\"false\" errinfo=\"" + "错误信息" + "\"/></result>"; //返回false 不执行Excute }
private void CalcBody_zzg(UFIDA.U8.UAP.UI.Runtime.Common.CellChangeEventArgs para, BusinessProxy businessObject, VoucherProxy voucherObject) { string entityID = businessObject.EntityID; if (NeExpense.config.ContainsKey(entityID)) { CheckConfig checkConfig = NeExpense.config[(entityID)]; if (checkConfig.ChangedColName == para.ColumnName) { VoucherSrv voucherSrv = new VoucherSrv(); string text = checkConfig.CheckSql.Replace("@ret", para.NewValue); DataSet dataSet = voucherSrv.ExcuteSqlInData(text); DataRow dataRow = null; if (dataSet != null && dataSet.Tables != null && dataSet.Tables[0] != null && dataSet.Tables[0].Rows.Count > 0) { dataRow = dataSet.Tables[0].Rows[0]; } if (dataRow != null) { using (Dictionary<string, string>.KeyCollection.Enumerator enumerator = checkConfig.WriteCol.Keys.GetEnumerator()) { while (enumerator.MoveNext()) { string current = enumerator.Current; businessObject.Cells[current].Value = dataRow[checkConfig.WriteCol[current]].ToString(); } } } } } }
/// <summary> /// 按钮事情真正执行 /// </summary> /// <param name="ReceiptObject"></param> /// <param name="PreExcuteResult"></param> /// <returns></returns> public string Excute(VoucherProxy ReceiptObject, string PreExcuteResult) { //Business business = ReceiptObject.Businesses["表体实体ID"]; //取表体实体 //string str = business.Rows[0].Cells["列名称"].Value; //取表体第一行 某列的值 ////增加少量数据可以通过修改实体的方式,但是这种方式会有性能问题,每次修改单元格 都会导致界面刷新。 //Business subEntity = ReceiptObject.Businesses["U8CUSTDEF_0004_E002"];//子表实体 U8CUSTDEF_0004_E002是子表实体编号,可以在UAP中看到 //for (int i = 0; i < 10; i++) //{ // string rowKey = subEntity.AddRow(); //rowKey是行 主键值 // subEntity.Rows[rowKey].Cells["fQuantity"].Value = "1"; // subEntity.Rows[rowKey].Cells["fPrice"].Value = "1"; // subEntity.Rows[rowKey].Cells["fAmount"].Value = "1"; // subEntity.Rows[rowKey].Cells["cDetailMemo"].Value = "备注" + i.ToString(); //} string sErr = ""; try { SqlConnection conn = new SqlConnection(_LoginInfo.UFDataSqlConStr); conn.Open(); SqlTransaction tran = conn.BeginTransaction(); try { #region 读取数据 DataSet ds = ReceiptObject.GetData(false, false); DataTable dtHad = ds.Tables[0]; DataTable dtDs = ds.Tables[1]; DateTime dtmLogin = BaseFunction.ReturnDate(dtHad.Rows[0]["dDate"]); int year = dtmLogin.Year; int month = dtmLogin.Month; string sVouCode = dtHad.Rows[0]["cCode"].ToString().Trim(); if (sVouCode == "") { string msg = sGetLanguage("获取单据号失败"); throw new Exception(msg); } //应收是否结账 string sSQL = "select isnull(bflag_AP,0) as bflag_AP from GL_mend where iyear = {0} and iperiod = {1}"; sSQL = string.Format(sSQL, year, month); DataTable dtTemp = DbHelperSQL.ExecuteDataset(tran, CommandType.Text, sSQL).Tables[0]; if (dtTemp != null && dtTemp.Rows.Count > 0 && BaseFunction.ReturnBool(dtTemp.Rows[0]["bflag_AP"])) { string msg = sGetLanguage("已经结账"); throw new Exception(msg); } #region 检查汇兑损益基础档案 sSQL = @" select * from TH_ArAp_Set "; DataTable dtSet = DbHelperSQL.ExecuteDataset(tran, CommandType.Text, sSQL).Tables[0]; if (dtSet == null || dtSet.Rows.Count == 0) { string msg = sGetLanguage("请设置基础档案"); throw new Exception(msg); } //摘要 - 汇兑损益已实现 string sDigest = dtSet.Rows[0]["cDigest"].ToString().Trim(); if (sDigest == "") { string msg = sGetLanguage("请设置摘要"); throw new Exception(msg); } //凭证类别 - 汇兑损益已实现 string sSign = dtSet.Rows[0]["cSign"].ToString().Trim(); if (sSign == "") { string msg = sGetLanguage("请设置凭证类别"); throw new Exception(msg); } //会计科目 - 汇兑损益已实现 string sDeptor = dtSet.Rows[0]["Deptor"].ToString().Trim(); string sCredit = dtSet.Rows[0]["Credit"].ToString().Trim(); if (sDeptor == "" || sCredit == "") { string msg = sGetLanguage("请设置会计科目"); throw new Exception(msg); } #endregion DateTime dtmStart = BaseFunction.ReturnDate(year + "-" + month + "-01"); DateTime dtmEnd = dtmStart.AddMonths(1); sSQL = @" select cexch_code,cexch_name from dbo.foreigncurrency where iotherused = -1 "; DataTable dtLocal = DbHelperSQL.ExecuteDataset(tran, CommandType.Text, sSQL).Tables[0]; if (dtLocal.Rows.Count == 0) { string msg = sGetLanguage("未设置本币币种"); throw new Exception(msg); } string localExName = dtLocal.Rows[0]["cexch_name"].ToString(); #endregion //判断是否审核 sSQL = @" select distinct ISNULL(cAuditor,'') as cAuditor from TH_AP_HDSY where 1=1 and year(dDate) = {0} and month(dDate) = {1} "; sSQL = string.Format(sSQL, year, month); dtTemp = DbHelperSQL.ExecuteDataset(tran, CommandType.Text, sSQL).Tables[0]; if (dtTemp == null || dtTemp.Rows.Count == 0 || dtTemp.Rows[0][0].ToString().Trim() == "") { string msg = sGetLanguage("单据尚未审核"); throw new Exception(msg); } //判断凭证是否已经生成 sSQL = @" select distinct isnull(PZH, '') as PZH from TH_AP_HDSY a inner join TH_AP_HDSYs b on a.TH_AP_HDSY_PK = b.TH_AP_HDSY_PK where 1=1 and a.cCode = '{0}' "; sSQL = string.Format(sSQL, sVouCode); DataTable dtExists = DbHelperSQL.ExecuteDataset(tran, CommandType.Text, sSQL).Tables[0]; if (dtExists != null && dtExists.Rows.Count > 0) { long i_id = BaseFunction.ReturnLong(dtExists.Rows[0]["PZH"]); sSQL = @" select * from GL_accvouch where 1=1 and isnull(iflag,0) = 0 and iyear = {0} and iperiod = {1} and (i_id = {2}) "; sSQL = string.Format(sSQL, year, month, i_id); DataTable dt = DbHelperSQL.ExecuteDataset(tran, CommandType.Text, sSQL).Tables[0]; if (dt != null && dt.Rows.Count > 0) { string msg = sGetLanguage("已经生成凭证"); throw new Exception(msg); } } sSQL = @" select a.cCode,a.cAuditor,b.dRate,b.exchname ,SUM(b.iAmount_f1) as iExchSum ,SUM(b.HDSY) AS HDSY from TH_AP_HDSY a inner join TH_AP_HDSYs b on a.TH_AP_HDSY_PK = b.TH_AP_HDSY_PK where a.cCode = '{0}' group by a.cCode,a.cAuditor,b.dRate,b.exchname order by b.exchname "; sSQL = string.Format(sSQL, sVouCode); DataTable dtDetails = DbHelperSQL.ExecuteDataset(tran, CommandType.Text, sSQL).Tables[0]; ////大数据刷新显示 //ReceiptObject.Refresh(ds); int iCount = 0; int iRow = 0; string sVouchCode = ""; #region 生成凭证 - 汇兑损益已实现 //获得凭证号 sSQL = "select isnull(max(ino_id),0) from GL_accvouch where iyear = {0} AND iperiod = {1} and csign = '{2}'"; sSQL = string.Format(sSQL, year, month, sSign); DataTable dtinoid = DbHelperSQL.ExecuteDataset(tran, CommandType.Text, sSQL).Tables[0]; int ino_id1 = BaseFunction.ReturnInt(dtinoid.Rows[0][0]) + 1; for (int i = 0; i < dtDetails.Rows.Count; i++) { decimal dHDSY = BaseFunction.ReturnDecimal(dtDetails.Rows[i]["HDSY"]); if (dHDSY != 0) { sSQL = @" select isignseq from dsign where csign = '{0}' "; sSQL = string.Format(sSQL, sSign); dtTemp = DbHelperSQL.ExecuteDataset(tran, CommandType.Text, sSQL).Tables[0]; iRow += 1; #region 借方 Model.GL_accvouch model = new Model.GL_accvouch(); model.iperiod = BaseFunction.ReturnInt(month); model.csign = sSign; model.isignseq = BaseFunction.ReturnInt(dtTemp.Rows[0]["isignseq"]); model.ino_id = ino_id1; model.inid = iRow; model.dbill_date = _LoginInfo.LoginDate; model.idoc = 0; model.cbill = _LoginInfo.UserName; model.ibook = 0; model.cdigest = sDigest; model.ccode = sDeptor; //model.cDefine1 = sDocment2; model.md = BaseFunction.ReturnDecimal(dHDSY, 2); model.mc = 0; model.md_f = 0; model.mc_f = 0; model.nfrat = 0; model.nd_s = 0; model.nc_s = 0; //model.csettle = ""; //结算方式 //model.cn_id //model.dt_date = model.ccode_equal = sCredit; model.bdelete = false; //model.doutbilldate = model.dbill_date; model.bvouchedit = true; model.bvouchAddordele = false; model.bvouchmoneyhold = false; model.bvalueedit = true; model.bcodeedit = true; model.bPCSedit = true; model.bDeptedit = true; model.bItemedit = true; model.bCusSupInput = false; model.bFlagOut = false; model.RowGuid = Guid.NewGuid().ToString(); model.iyear = BaseFunction.ReturnInt(year); model.iYPeriod = BaseFunction.ReturnInt(BaseFunction.ReturnDate(year.ToString() + "-" + month.ToString() + "-01").ToString("yyyyMM")); model.tvouchtime = DateTime.Now; model.ccodeexch_equal = sCredit; DAL.GL_accvouch dalGL = new DAL.GL_accvouch(); sSQL = dalGL.Add(model); iCount = iCount + DbHelperSQL.ExecuteNonQuery(tran, CommandType.Text, sSQL); #endregion #region 贷方 iRow += 1; model = new Model.GL_accvouch(); model.iperiod = BaseFunction.ReturnInt(month); model.csign = sSign; model.isignseq = BaseFunction.ReturnInt(dtTemp.Rows[0]["isignseq"]); model.ino_id = ino_id1; model.inid = iRow; model.dbill_date = _LoginInfo.LoginDate; model.idoc = 0; model.cbill = _LoginInfo.UserName; model.ibook = 0; model.cdigest = sDigest; model.ccode = sCredit; //model.cDefine1 = sDocment2; model.mc = 0; model.md = -1 * BaseFunction.ReturnDecimal(dHDSY, 2); model.md_f = 0; model.mc_f = 0; model.nfrat = 0; model.nd_s = 0; model.nc_s = 0; //model.csettle = ""; //结算方式 //model.cn_id //model.dt_date = model.ccode_equal = sDeptor; model.bdelete = false; model.doutbilldate = model.dbill_date; model.bvouchedit = true; model.bvouchAddordele = false; model.bvouchmoneyhold = false; model.bvalueedit = true; model.bcodeedit = true; model.bPCSedit = true; model.bDeptedit = true; model.bItemedit = true; model.bCusSupInput = false; model.bFlagOut = false; model.RowGuid = Guid.NewGuid().ToString(); model.iyear = BaseFunction.ReturnInt(year); model.iYPeriod = BaseFunction.ReturnInt(BaseFunction.ReturnDate(year.ToString() + "-" + month.ToString() + "-01").ToString("yyyyMM")); model.tvouchtime = DateTime.Now; model.ccodeexch_equal = sDeptor; dalGL = new DAL.GL_accvouch(); sSQL = dalGL.Add(model); iCount = iCount + DbHelperSQL.ExecuteNonQuery(tran, CommandType.Text, sSQL); #endregion } } if (iCount > 0) { sSQL = @" select i_id from GL_accvouch where iyear = {0} AND iperiod = {1} and csign = '{2}' and ino_id = {3} "; sSQL = string.Format(sSQL, year, month, sSign, ino_id1); DataTable dt_Exists = DbHelperSQL.ExecuteDataset(tran, CommandType.Text, sSQL).Tables[0]; sSQL = @" update TH_AP_HDSYs set PZH = '{0}' where TH_AP_HDSY_PK in (select TH_AP_HDSY_PK from TH_AP_HDSY where year(dDate) = {1} and month(dDate) = {2}) "; sSQL = string.Format(sSQL, dt_Exists.Rows[0]["i_id"], year, month); DbHelperSQL.ExecuteNonQuery(tran, CommandType.Text, sSQL); sVouchCode = sVouchCode + sSign + "-" + ino_id1.ToString().PadLeft(4, '0'); } #endregion //大数据刷新显示 //ReceiptObject.Refresh(ds); tran.Commit(); string sMsg = sGetLanguage("生成凭证成功"); sMsg = sMsg + ":\n" + sVouchCode; MessageBox.Show(sMsg); return(null); } catch (Exception ee) { tran.Rollback(); throw new Exception(ee.Message); } finally { conn.Close(); } } catch (Exception ee) { MessageBox.Show(ee.Message); return("<result><system result=\"false\" errinfo=\"" + ee.Message + "\"/></result>"); //返回false 不执行Excuted } }
private const string gwc_traceErrorField = "cNeDefine10";//公务卡查询错误信息 private void CalcHead_Money(VoucherProxy voucherObject) { Business body = voucherObject.Businesses["a701a36d-ec4f-43c9-b95a-ef77d7600f57"]; Business head = voucherObject.Businesses["12f73210-161b-4d45-94a0-6589e1ec7ae2"]; double num = 0.0; int count = body.Rows.Count; for (int i = 0; i < count; i++) { if (body.Rows[i].Cells["ExpenseMoney"].Value == null || body.Rows[i].Cells["ExpenseMoney"].Value == "") continue; num += Convert.ToDouble(body.Rows[i].Cells["ExpenseMoney"].Value); } head.Rows[0].Cells["ExpenseMoney"].Value = (num.ToString("0.00")); head.Rows[0].Cells["LocalMoney"].Value = (num.ToString("0.00")); }
private void CalcBody_Tax_LWOTH(BusinessProxy businessObject, VoucherProxy voucherObject) { //Business body = voucherObject.Businesses["a701a36d-ec4f-43c9-b95a-ef77d7600f57"]; Business head = voucherObject.Businesses["12f73210-161b-4d45-94a0-6589e1ec7ae2"]; //15.6.25 劳务费外外聘时需要 表体根据报销金额,算税。 string exid = businessObject.Cells["ExpenserID"].Value; string voucherid = head.Cells["ID"].Value; string amount = businessObject.Cells["ExpenseMoney"].Value; string cNeDefine13 = businessObject.Cells["cNeDefine13"].Value; if (!string.IsNullOrEmpty(exid) && !string.IsNullOrEmpty(amount) && !string.IsNullOrEmpty(cNeDefine13)) { VoucherSrv voucherSrv = new VoucherSrv(); string text = "exec P_SW_NE_CalcTax '" + exid + "','" + voucherid + "','" + amount + "','" + cNeDefine13 + "'"; DataSet dataSet = voucherSrv.ExcuteSqlInData(text); if (dataSet != null && dataSet.Tables != null && dataSet.Tables.Count > 0 && dataSet.Tables[0].Rows.Count > 0) { DataRow dataRow = dataSet.Tables[0].Rows[0]; businessObject.Cells["cNeDefine22"].Value = dataRow[0].ToString(); //税额 decimal damount = 0, dtax = 0,dpay = 0; decimal.TryParse(amount, out damount); decimal.TryParse(dataRow[0].ToString(), out dtax); dpay = damount - dtax; dpay = Math.Round(dpay, 2); businessObject.Cells["cNeDefine23"].Value = dpay.ToString("0.00"); //实发金额 } } }
private void CalcBody_RefTypeVID(UFIDA.U8.UAP.UI.Runtime.Common.CellChangeEventArgs para, BusinessProxy businessObject, VoucherProxy voucherObject) { //15.6.25表体报销人带其它 信息。 string exid = null; if (para.NewHiddenValue != null) exid = para.NewHiddenValue.ToString(); CalcBody_RefTypeVID(exid, businessObject, voucherObject); }
public override void CellChanged(UFIDA.U8.UAP.UI.Runtime.Common.CellChangeEventArgs para, BusinessProxy businessObject, VoucherProxy voucherObject) { base.CellChanged(para, businessObject, voucherObject); if (NeExpense.config == null) { NeExpense.config = CheckConfig.Init(); } if (businessObject.EntityID == "a701a36d-ec4f-43c9-b95a-ef77d7600f57") //表体 { if (para.ColumnName == "ExpenseMoney") { CalcBody_ReCalcBXAmount(para, businessObject, voucherObject); if (voucherObject.Businesses["12f73210-161b-4d45-94a0-6589e1ec7ae2"].Cells["OperationTypeCode"].Value == "O") CalcBody_Tax_LWOTH(businessObject, voucherObject); //从表头报销人会自动带到表体,不触发事件,所以在金额处再补带一次。 string exposerID = businessObject.Cells["ExpenserID"].Value; //string cNeDefine12 = businessObject.Cells["cNeDefine12"].Value; if (!string.IsNullOrEmpty(exposerID))//&& string.IsNullOrEmpty(cNeDefine12)) { CalcBody_RefTypeVID(exposerID, businessObject, voucherObject); } queryICBC(businessObject, voucherObject); } else if (para.ColumnName == "ExpenserID") { CalcBody_RefTypeVID(para, businessObject, voucherObject); if (voucherObject.Businesses["12f73210-161b-4d45-94a0-6589e1ec7ae2"].Cells["OperationTypeCode"].Value == "O") { CalcBody_Tax_LWOTH(businessObject, voucherObject); } queryICBC(businessObject, voucherObject); } else if (para.ColumnName == "cNeDefine13")//手动录入身份证号,并计算税。 { if (voucherObject.Businesses["12f73210-161b-4d45-94a0-6589e1ec7ae2"].Cells["OperationTypeCode"].Value == "O") CalcBody_Tax_LWOTH(businessObject, voucherObject); } else if (para.ColumnName == gwc_traceDateField) //公务卡日期。 { queryICBC(businessObject, voucherObject); } } else if (businessObject.EntityID == "12f73210-161b-4d45-94a0-6589e1ec7ae2") //表头 { if (para.ColumnName == "cDefine13") { if (para.NewValue == "公务卡") { voucherObject.SetPortalButtonEnabled("btnSWRefConsume", true); } else if (para.OldValue == "公务卡" && para.NewValue != "公务卡") { voucherObject.Businesses["a701a36d-ec4f-43c9-b95a-ef77d7600f57"].Clear(); voucherObject.SetPortalButtonEnabled("btnSWRefConsume", false); } } } CalcBody_zzg(para, businessObject, voucherObject); }
/// <summary> /// 按钮事情真正执行 /// </summary> /// <param name="ReceiptObject"></param> /// <param name="PreExcuteResult"></param> /// <returns></returns> public string Excute(VoucherProxy ReceiptObject, string PreExcuteResult) { //Business business = ReceiptObject.Businesses["表体实体ID"]; //取表体实体 //string str = business.Rows[0].Cells["列名称"].Value; //取表体第一行 某列的值 ////增加少量数据可以通过修改实体的方式,但是这种方式会有性能问题,每次修改单元格 都会导致界面刷新。 //Business subEntity = ReceiptObject.Businesses["U8CUSTDEF_0004_E002"];//子表实体 U8CUSTDEF_0004_E002是子表实体编号,可以在UAP中看到 //for (int i = 0; i < 10; i++) //{ // string rowKey = subEntity.AddRow(); //rowKey是行 主键值 // subEntity.Rows[rowKey].Cells["fQuantity"].Value = "1"; // subEntity.Rows[rowKey].Cells["fPrice"].Value = "1"; // subEntity.Rows[rowKey].Cells["fAmount"].Value = "1"; // subEntity.Rows[rowKey].Cells["cDetailMemo"].Value = "备注" + i.ToString(); //} string sErr = ""; try { SqlConnection conn = new SqlConnection(_LoginInfo.UFDataSqlConStr); conn.Open(); SqlTransaction tran = conn.BeginTransaction(); try { DataSet ds = ReceiptObject.GetData(false, false); DataTable dtHad = ds.Tables[0]; if (dtHad.Rows.Count == 0) { string msg = sGetLanguage("没有数据"); throw new Exception(msg); } string year = BaseFunction.ReturnDate(dtHad.Rows[0]["dDate"]).Year.ToString(); if (year == "") { string msg = sGetLanguage("请指定年"); throw new Exception(msg); } string month = BaseFunction.ReturnDate(dtHad.Rows[0]["dDate"]).Month.ToString(); if (month == "") { string msg = sGetLanguage("请指定月"); throw new Exception(msg); } string sVouCode = dtHad.Rows[0]["cCode"].ToString().Trim(); if (sVouCode == "") { string msg = sGetLanguage("获取单据号失败"); throw new Exception(msg); } //判断凭证是否已经生成 string sSQL = @" select distinct isnull(PZH, '') as PZH from TH_AR_HDSY a inner join TH_AR_HDSYs b on a.TH_AR_HDSY_PK = b.TH_AR_HDSY_PK where 1=1 and a.cCode = '{0}' "; sSQL = string.Format(sSQL, sVouCode); DataTable dtExists = DbHelperSQL.ExecuteDataset(tran, CommandType.Text, sSQL).Tables[0]; if (dtExists != null && dtExists.Rows.Count > 0) { long i_id = BaseFunction.ReturnLong(dtExists.Rows[0]["PZH"]); sSQL = @" select * from GL_accvouch where 1=1 and isnull(iflag,0) = 0 and iyear = {0} and iperiod = {1} and (i_id = {2} ) "; sSQL = string.Format(sSQL, year, month, i_id); DataTable dt = DbHelperSQL.ExecuteDataset(tran, CommandType.Text, sSQL).Tables[0]; if (dt != null && dt.Rows.Count > 0) { string msg = sGetLanguage("已经生成凭证,不能弃审"); throw new Exception(msg); } } tran.Commit(); return(null); } catch (Exception ee) { tran.Rollback(); throw new Exception(ee.Message); } finally { conn.Close(); } } catch (Exception ee) { MessageBox.Show(ee.Message); return("<result><system result=\"false\" errinfo=\"" + ee.Message + "\"/></result>"); //返回false 不执行Excuted } }
public string Excuting(VoucherProxy ReceiptObject) { return this.MakeExcuteState(true, ""); }
/// <summary> /// 按钮事件执行后 /// </summary> /// <param name="ReceiptObject"></param> /// <param name="PreExcuteResult"></param> /// <returns></returns> public string Excuted(VoucherProxy ReceiptObject, string PreExcuteResult) { return(string.Empty); }
private void queryICBC(BusinessProxy businessObject, VoucherProxy voucherObject) { //queryICBC_QueryEnd(null, null); //return; UAPDebug.WriteLine("", this, System.Reflection.MethodBase.GetCurrentMethod(), "公务卡-开始查询"); string exposerID = businessObject.Cells["ExpenserID"].Value; if (string.IsNullOrEmpty(exposerID)) { UAPDebug.WriteLine("", this, System.Reflection.MethodBase.GetCurrentMethod(), "公务卡-报销人为空"); return; } string date = businessObject.Cells[gwc_traceDateField].Value; string amountS = businessObject.Cells["ExpenseMoney"].Value; string card = null; string name = null; if (string.IsNullOrEmpty(date) || string.IsNullOrEmpty(amountS)) { UAPDebug.WriteLine("", this, System.Reflection.MethodBase.GetCurrentMethod(), "公务卡-日期或金额为空"); return; } float famount = 0f; float.TryParse(amountS, out famount); if (famount < 0.001) { UAPDebug.WriteLine("", this, System.Reflection.MethodBase.GetCurrentMethod(), "公务卡-金额小于0"); return; } Int64 iamount = Convert.ToInt64(famount * 100); string amount = iamount.ToString(); VoucherSrv voucherSrv = new VoucherSrv(); string text = "select cPsn_Name,cbankaccount from hr_hi_Person j join hr_hi_bankaccount a on j.cpsn_num=a.cpsn_num where j.cpsn_num='" + exposerID + "'"; DataSet dataSet = voucherSrv.ExcuteSqlInData(text); if (dataSet != null && dataSet.Tables != null && dataSet.Tables.Count > 0 && dataSet.Tables[0].Rows.Count > 0) { DataRow dataRow = dataSet.Tables[0].Rows[0]; card = dataRow["cbankaccount"].ToString(); name = dataRow["cPsn_Name"].ToString(); } if (string.IsNullOrEmpty(card) || string.IsNullOrEmpty(name)) { UAPDebug.WriteLine("", this, System.Reflection.MethodBase.GetCurrentMethod(), "公务卡-卡号或姓名为空"); return; } UAPDebug.WriteLine("", this, System.Reflection.MethodBase.GetCurrentMethod(), "公务卡-开始准备ICBC参数,date=" + date + ",amount=" + amount + ",card=" + card + ",name=" + name); QueryICBC query = new QueryICBC("GB2312", date, null, amount, card, name); // public object businessObject { get; set; } // public object voucherObject { get; set; } query.businessObject = businessObject; query.voucherObject = voucherObject; query.QueryEnd += new EventHandler(queryICBC_QueryEnd); query.QueryError += new EventHandler(query_QueryError); //query.QueryAsyn(); query.QueryProxy(); UAPDebug.WriteLine("", this, System.Reflection.MethodBase.GetCurrentMethod(), "公务卡-调用ICBC,异步结束"); }
public string Excute(VoucherProxy ReceiptObject, string PreExcuteResult) { return this.MakeExcuteState(true, ""); }
public override Control CreateControl(BusinessProxy businessObject, VoucherProxy voucherObject, string ID) { Control resultControl = null; return(resultControl); }
public override IButtonEventHandler GetButtonEventHandler(VoucherButtonArgs ButtonArgs, VoucherProxy voucherObject) { switch (ButtonArgs.ButtonKey) { //应收读取汇兑损益业务数据 case "BtnAR_ReadData": { return(new BtnAR_ReadData(voucherObject.LoginInfo)); } //创建应收汇兑损益凭证 case "BtnAR_CreateAccountingDocument": { return(new BtnAR_CreateAccountingDocument(voucherObject.LoginInfo)); } //弃审 case "btnAbandonAudit": { return(new BtnAR_UnAudit(voucherObject.LoginInfo)); } default: return(null); } }
private void CalcBody_RefTypeVID(string exposerID, BusinessProxy businessObject, VoucherProxy voucherObject) { return;//身份证号手动录入不自动带了 //15.6.25表体报销人带其它 信息。 string exid = exposerID; if (!string.IsNullOrEmpty(exid)) { VoucherSrv voucherSrv = new VoucherSrv(); string text = "select vIDNo,rPersonType,vsimpleName from hr_hi_Person p left join hr_ct000 c on p.rPersonType=c.ccodeID where cpsn_num='" + exid + "'"; DataSet dataSet = voucherSrv.ExcuteSqlInData(text); if (dataSet != null && dataSet.Tables != null && dataSet.Tables.Count > 0 && dataSet.Tables[0].Rows.Count > 0) { DataRow dataRow = dataSet.Tables[0].Rows[0]; //businessObject.Cells["cNeDefine12"].Value = dataRow["vsimpleName"].ToString(); //人员类别 15.7.15 改成姓名了。 businessObject.Cells["cNeDefine13"].Value = dataRow["vIDNo"].ToString(); //身份证 } } else { //businessObject.Cells["cNeDefine12"].Value = null; //人员类别 businessObject.Cells["cNeDefine13"].Value = null; //身份证 } }
public override void ReceiptLoaded(VoucherProxy ReceiptObject) { }
/// <summary> /// 按钮事情真正执行 /// </summary> /// <param name="ReceiptObject"></param> /// <param name="PreExcuteResult"></param> /// <returns></returns> public string Excute(VoucherProxy ReceiptObject, string PreExcuteResult) { //Business business = ReceiptObject.Businesses["表体实体ID"]; //取表体实体 //string str = business.Rows[0].Cells["列名称"].Value; //取表体第一行 某列的值 ////增加少量数据可以通过修改实体的方式,但是这种方式会有性能问题,每次修改单元格 都会导致界面刷新。 //Business subEntity = ReceiptObject.Businesses["U8CUSTDEF_0004_E002"];//子表实体 U8CUSTDEF_0004_E002是子表实体编号,可以在UAP中看到 //for (int i = 0; i < 10; i++) //{ // string rowKey = subEntity.AddRow(); //rowKey是行 主键值 // subEntity.Rows[rowKey].Cells["fQuantity"].Value = "1"; // subEntity.Rows[rowKey].Cells["fPrice"].Value = "1"; // subEntity.Rows[rowKey].Cells["fAmount"].Value = "1"; // subEntity.Rows[rowKey].Cells["cDetailMemo"].Value = "备注" + i.ToString(); //} string sErr = ""; try { SqlConnection conn = new SqlConnection(_LoginInfo.UFDataSqlConStr); conn.Open(); SqlTransaction tran = conn.BeginTransaction(); try { #region 读取数据 DataSet ds = ReceiptObject.GetData(false, false); DataTable dtHad = ds.Tables[0]; DataTable dtDs = ds.Tables[1]; if (dtHad.Rows.Count == 0) { string msg = sGetLanguage("没有数据"); throw new Exception(msg); } //string year = dtHad.Rows[0]["iYear"].ToString(); //if (year == "") //{ // string msg = sGetLanguage("请指定年"); // throw new Exception(msg); //} //string month = dtHad.Rows[0]["iPeriod"].ToString(); //if (month == "") //{ // string msg = sGetLanguage("请指定月"); // throw new Exception(msg); //} dtHad.Rows[0]["dDate"] = _LoginInfo.LoginDate; DateTime dtmLog = _LoginInfo.LoginDate; int year = dtmLog.Year; int month = dtmLog.Month; //if (BaseFunction.ReturnInt(year) != _LoginInfo.LoginDate.Year || BaseFunction.ReturnInt(month) != _LoginInfo.LoginDate.Month) //{ // string msg = sGetLanguage("登陆日期不正确"); // throw new Exception(msg); //} //string sCode = dtHad.Rows[0]["cCode"].ToString(); //if (sCode == "") //{ // string msg = sGetLanguage("请选择单据"); // throw new Exception(msg); //} //string sAudit = dtHad.Rows[0]["cAuditor"].ToString(); //if (sAudit == "") //{ // string msg = sGetLanguage("单据尚未审核"); // throw new Exception(msg); //} ////应收是否结账 //string sSQL = "select isnull(bflag_AR,0) as bflag_AR from GL_mend where iyear = {0} and iperiod = {1}"; //sSQL = string.Format(sSQL, year, month); //DataTable dtTemp = DbHelperSQL.ExecuteDataset(tran, CommandType.Text, sSQL).Tables[0]; //if (dtTemp != null && dtTemp.Rows.Count > 0 && BaseFunction.ReturnBool(dtTemp.Rows[0]["bflag_AR"])) //{ // string msg = sGetLanguage("已经结账"); // throw new Exception(msg); //} #region 检查汇兑损益基础档案 string sSQL = @" select * from TH_ArAp_Set "; DataTable dtSet = DbHelperSQL.ExecuteDataset(tran, CommandType.Text, sSQL).Tables[0]; //摘要 if (dtSet.Rows[0]["cDigest"].ToString().Trim() == "") { string msg = sGetLanguage("请设置摘要"); throw new Exception(msg); } //凭证类别 if (dtSet.Rows[0]["cSign"].ToString().Trim() == "") { string msg = sGetLanguage("请设置凭证类别"); throw new Exception(msg); } //会计科目 if (dtSet.Rows[0]["Deptor"].ToString().Trim() == "" || dtSet.Rows[0]["Credit"].ToString().Trim() == "") { string msg = sGetLanguage("请设置会计科目"); throw new Exception(msg); } #endregion sSQL = @" select cCode from TH_AR_HDSY where year(dDate) = {0} and month(dDate) = {1} "; sSQL = string.Format(sSQL, year, month); DataTable dt = DbHelperSQL.ExecuteDataset(tran, CommandType.Text, sSQL).Tables[0]; if (dt != null && dt.Rows.Count > 0) { string msg = sGetLanguage("当前期间已有数据"); throw new Exception(msg); } DateTime dtmStart = BaseFunction.ReturnDate(year + "-" + month + "-01"); DateTime dtmEnd = dtmStart.AddMonths(1); sSQL = @" select cexch_code,cexch_name from dbo.foreigncurrency where iotherused = -1 "; DataTable dtLocal = DbHelperSQL.ExecuteDataset(tran, CommandType.Text, sSQL).Tables[0]; if (dtLocal.Rows.Count == 0) { string msg = sGetLanguage("未设置本币币种"); throw new Exception(msg); } string localExName = dtLocal.Rows[0]["cexch_name"].ToString(); #endregion Business subEntity = ReceiptObject.Businesses["TH170901_0002_E002"]; subEntity.Clear(); sSQL = @" exec [_TH_Get_AR] '{0}' "; sSQL = string.Format(sSQL, dtmLog.ToString("yyyy-MM-dd")); DataTable dtDetails = DbHelperSQL.ExecuteDataset(tran, CommandType.Text, sSQL).Tables[0]; ////大数据刷新显示 ReceiptObject.Refresh(ds); for (int i = 0; i < dtDetails.Rows.Count; i++) { // DataRow dr = dtSub.NewRow(); // dr["UAPAR001_0001_E001_PK"] = ReceiptObject.CurrentPKValue; //必须给子表的外键 赋值,子表的外键值=主表的主键值 string rowKey = subEntity.AddRow(); //rowKey是行 主键值 subEntity.Rows[rowKey].Cells["ctypename1"].Value = sGetLanguage(dtDetails.Rows[i]["ctypename1"].ToString().Trim()); //单据类型 subEntity.Rows[rowKey].Cells["cvouchid1"].Value = dtDetails.Rows[i]["cvouchid1"].ToString().Trim(); //业务单据号 subEntity.Rows[rowKey].Cells["dVouchDate1"].Value = dtDetails.Rows[i]["dVouchDate1"].ToString().Trim(); //单据日期 subEntity.Rows[rowKey].Cells["cDwCode"].Value = dtDetails.Rows[i]["cDwCode"].ToString().Trim(); //客户编码 subEntity.Rows[rowKey].Cells["cDwName"].Value = dtDetails.Rows[i]["cDwName"].ToString().Trim(); //客户名称 subEntity.Rows[rowKey].Cells["exchname"].Value = dtDetails.Rows[i]["exchname"].ToString().Trim(); //币种 subEntity.Rows[rowKey].Cells["iAmount_f1"].Value = dtDetails.Rows[i]["iAmount_f1"].ToString().Trim(); //本期核销金额 subEntity.Rows[rowKey].Cells["dRate"].Value = dtDetails.Rows[i]["dRate"].ToString().Trim(); //汇率 subEntity.Rows[rowKey].Cells["HDSY"].Value = dtDetails.Rows[i]["HDSY"].ToString().Trim(); //汇兑损益 } //大数据刷新显示 //ReceiptObject.Refresh(ds); tran.Commit(); string sMsg = sGetLanguage("读取数据成功"); MessageBox.Show(sMsg); return(null); } catch (Exception ee) { tran.Rollback(); throw new Exception(ee.Message); } finally { conn.Close(); } } catch (Exception ee) { MessageBox.Show(ee.Message); return("<result><system result=\"false\" errinfo=\"" + ee.Message + "\"/></result>"); //返回false 不执行Excuted } }