public string AddPurchase(BMGHDWModel purchase) { return(this.AddPurchaseKP(purchase, 0)); }
protected override object[] doService(object[] param) { BMGHDWModel model; if (!CheckPermission.Check("GHDW")) { return(null); } if (param.Length < 3) { throw new ArgumentException("参数错误,至少有3个参数"); } string mC = (param[0] as string).Trim(); string taxCode = (param[1] as string).Trim(); string str3 = (param[2] as string).Trim(); if (mC.Length == 0) { MessageBoxHelper.Show("请输入购货单位名称", "输入提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return(new object[] { "Cancel" }); } if (str3.Length == 0) { MessageBoxHelper.Show("请输入购货单位身份证号码/组织机构代码", "输入提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return(new object[] { "Cancel" }); } string str4 = ""; string sJBM = ""; switch (MessageBoxHelper.Show("是否有上级单位?", "输入确认", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question)) { case DialogResult.Cancel: return(new object[] { "Cancel" }); case DialogResult.Yes: { if ((taxCode.Length != 0) && (this.ghdwmanager.QueryByTaxCode(taxCode).Rows.Count > 0)) { MessageBoxHelper.Show("与此税号对应的购货单位已存在", "输入错误", MessageBoxButtons.OK, MessageBoxIcon.Hand); return(new object[] { "Error" }); } BMGHDWSelect select = new BMGHDWSelect(); if (select.ShowDialog() != DialogResult.OK) { return(new object[] { str4 }); } sJBM = select.SelectedSJBM; break; } } if (this.ghdwmanager.QueryByMCAndSJBM(mC, sJBM).Rows.Count > 0) { MessageBoxHelper.Show("新增购货单位名称与其同级单位名称重复!", "输入错误", MessageBoxButtons.OK, MessageBoxIcon.Hand); return(new object[] { "Error" }); } model = new BMGHDWModel { SJBM = sJBM, MC = mC, SH = taxCode, IDCOC = str3, WJ = 1 }; model.BM = this.ghdwmanager.TuiJianBM(model.SJBM); str4 = this.ghdwmanager.AddPurchaseKP(model, 1); if (str4 == "0") { str4 = "OK"; return(new object[] { str4 }); } this.log.Info("新增购货单位失败:" + str4); return(new object[] { "Error:", str4 }); }
public ImportResult ImportData(string codeFile) { ImportResult result2; try { string[] strArray = File.ReadAllLines(codeFile, ToolUtil.GetEncoding()); if (strArray.Length == 0) { throw new CustomException("此文件没有内容"); } string str = ""; int index = 0; bool flag = true; while (flag) { if (strArray[index].StartsWith("{购货单位编码}")) { string str2 = strArray[index]; if (!str2.Contains("\"")) { throw new CustomException("此文件首行购货单位编码没有指定分隔符,分隔符使用双引号标注"); } str = str2.Substring(str2.IndexOf("\"")).Trim().Trim(new char[] { '"' }); flag = false; index++; } else { index++; if (index == strArray.Length) { throw new CustomException("此文件不符合购货单位编码文本格式"); } } } ImportResult result = new ImportResult(); Stack <lastBMJG> stack = new Stack <lastBMJG>(); string str4 = this.TuiJianBM(""); string str5 = ""; bool flag2 = false; for (int i = index; i < strArray.Length; i++) { BMGHDWModel model; string lineText = strArray[i].Trim(); if (((lineText.Length == 0) || lineText.StartsWith("//")) || !lineText.Contains(str)) { continue; } string[] strArray2 = GetSafeData.Split(lineText, str); if (strArray2.Length < 3) { throw new CustomException("文本首行指定的分隔符与实际分隔符不一致,\n格式不正确等原因导致不能导入此文件!"); } model = new BMGHDWModel { BM = strArray2[0], MC = strArray2[1], JM = strArray2[2], }; model.KJM = CommonFunc.GenerateKJM(model.MC); string str7 = ""; string str8 = ""; ResultType none = ResultType.None; if (strArray2.Length <= 3) { goto Label_0307; } if (strArray2.Length < 7) { continue; } model.SH = strArray2[3].ToUpper(); model.WJ = 1; string str9 = ""; if (str == "~~") { str9 = strArray2[4].Replace(",", "\r\n").Replace("#|#", "\r\n"); } else if (str == " ") { str9 = strArray2[4].Replace("#|#", "\r\n"); } else { str9 = strArray2[4]; } model.DZDH = str9; string str10 = ""; if (str == "~~") { str10 = strArray2[5].Replace(",", "\r\n").Replace("#|#", "\r\n"); } else if (str == " ") { str10 = strArray2[5].Replace("#|#", "\r\n"); } else { str10 = strArray2[5]; } model.YHZH = str10; if (strArray2.Length <= 6) { goto Label_0307; } string str11 = string.Empty; string str13 = str; if (str13 == null) { goto Label_02F8; } if (!(str13 == "~~")) { if (str13 == " ") { goto Label_02D2; } goto Label_02F8; } str11 = strArray2[6].Replace(",", "\r\n").Replace("#|#", "\r\n"); goto Label_02FE; Label_02D2: str11 = strArray2[6].Replace(" ", "\r\n").Replace("#|#", "\r\n"); goto Label_02FE; Label_02F8: str11 = strArray2[6]; Label_02FE: model.IDCOC = str11; Label_0307: while (stack.Count > 0) { flag2 = false; if (model.BM.Length > stack.Peek().BM.Length) { if (!model.BM.StartsWith(stack.Peek().BM)) { goto Label_043E; } model.SJBM = stack.Peek().BM; if (stack.Peek().Result == ResultType.Invalid) { str7 = "无效"; str8 = "上级编码无效"; none = ResultType.Invalid; result.Invalid++; } else if (stack.Peek().Result == ResultType.Failed) { str7 = "失败"; str8 = "上级编码失败"; none = ResultType.Failed; result.Failed++; } else { if (stack.Peek().Result != ResultType.Duplicated) { goto Label_043E; } str5 = this.TuiJianBM(stack.Peek().BM); if (model.BM.Length == str5.Length) { goto Label_043E; } str7 = "无效"; str8 = "编码长度必须与原有同级编码长度一致"; result.Invalid++; none = ResultType.Invalid; } goto Label_06F3; } stack.Pop(); } flag2 = true; Label_043E: if ((flag2 && (str4 != "001")) && (model.BM.Length != str4.Length)) { str7 = "无效"; str8 = "编码长度必须与原有同级编码长度一致"; result.Invalid++; none = ResultType.Invalid; } else if ("0" != this.CheckPurchase(model)) { str7 = "无效"; str8 = "编码或名称为空"; result.Invalid++; none = ResultType.Invalid; } else if (!Regex.IsMatch(model.BM, "^[0-9a-z]{1,16}$")) { str7 = "无效"; str8 = "编码需小于16位,且仅由数字和小写字母组成"; result.Invalid++; none = ResultType.Invalid; } else if (this.bmghdwDAL.ExistPurchase(model)) { if (str7.Length == 0) { str7 = "重复"; result.Duplicated++; } if (str8.Length == 0) { str8 = "编码重复"; none = ResultType.Duplicated; } else { str8 = str8 + "且编码重复"; none = ResultType.Invalid; } } else if (((model.SH != null) && (model.SH.Length != 0)) && (((model.SH.Length < 6) || (model.SH.Length > 20)) || (((model.WJ == 1) && (model.SH.Length != 0)) && ("0000" != this.jyPurchase.CheckTaxCode(model.SH, (FPLX)12))))) { str7 = "失败"; str8 = "购货单位税号错误" + model.SH; result.Failed++; none = ResultType.Failed; } else if ((1 == model.WJ) && string.IsNullOrEmpty(model.IDCOC)) { str7 = "失败"; str8 = "身份证号码/组织机构代码不允许为空" + model.IDCOC; result.Failed++; none = ResultType.Failed; } else if (this.bmghdwDAL.ExistPurMC(model.BM, model.MC, model.SJBM)) { str7 = "失败"; str8 = "同级同族已存在同名购货单位" + model.SH; result.Failed++; none = ResultType.Failed; } else { StringUtils.GetSpellCode(model.MC); if (this.bmghdwDAL.AddPurchase(model) == "0") { str7 = "正确传入"; result.Correct++; none = ResultType.Correct; } else { str7 = "失败"; result.Failed++; none = ResultType.Failed; } } Label_06F3 :; result.DtResult.Rows.Add(new object[] { model.BM, model.MC, str7, str8 }); stack.Push(new lastBMJG(model.BM, none)); } result.ImportTable = "购货单位编码.DB"; result2 = result; } catch { throw; } return(result2); }