| | |
| | | using System.Data.SqlClient; |
| | | using System.Web.Http; |
| | | using WebAPI.Models; |
| | | using System.Text.RegularExpressions; |
| | | using SyntacticSugar.constant; |
| | | using System.Web; |
| | | using WebAPI.Controllers.SCGL.日计划管理; |
| | | using System.IO; |
| | | using SyntacticSugar.constant; |
| | | namespace WebAPI.Controllers |
| | | { |
| | | public class Gy_SupplierController : ApiController |
| | |
| | | } |
| | | } |
| | | |
| | | #region 供应商分页列表 |
| | | [Route("Gy_Supplier/page")] |
| | | [HttpGet] |
| | | public json Gy_SupplierPage(string sWhere, string user, int page, int size, string Organization) |
| | | { |
| | | DataSet ds; |
| | | json res = new json(); |
| | | try |
| | | { |
| | | List<object> columnNameList = new List<object>(); |
| | | //判断权限 |
| | | if (!DBUtility.ClsPub.Security_Log_second("Gy_Supplier", 1, false, user)) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "无查看权限!"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | sWhere += ("and 组织名称 = '" + Organization + "'"); |
| | | sWhere = sWhere.Replace("'", "''"); |
| | | if (sWhere == null || sWhere.Equals("")) |
| | | { |
| | | ds = oCN.RunProcReturn("exec h_p_Gy_SupplierList " + page + "," + size + ",''", "h_p_Gy_SupplierList"); |
| | | } |
| | | else |
| | | { |
| | | ds = oCN.RunProcReturn("exec h_p_Gy_SupplierList " + page + "," + size + ",'" + sWhere + "'", "h_p_Gy_SupplierList"); |
| | | } |
| | | |
| | | //添加列名 |
| | | foreach (DataColumn col in ds.Tables[0].Columns) |
| | | { |
| | | Type dataType = col.DataType; |
| | | string ColmString = "{\"ColmCols\":\"" + col.ColumnName + "\",\"ColmType\":\"" + dataType.Name + "\"}"; |
| | | columnNameList.Add(JsonConvert.DeserializeObject(ColmString));//获取到DataColumn列对象的列名 |
| | | } |
| | | |
| | | res.code = CodeConstant.SUCCEED; |
| | | res.count = int.Parse(ds.Tables[1].Rows[0]["count"].ToString()); |
| | | res.Message = "Sucess!"; |
| | | res.list = columnNameList; |
| | | res.data = ds.Tables[0]; |
| | | return res; |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | res.code = CodeConstant.FAIL; |
| | | res.count = CountConstant.FAIL; |
| | | res.Message = "Exception!" + e.ToString(); |
| | | res.data = null; |
| | | return res; |
| | | } |
| | | } |
| | | #endregion |
| | | |
| | | |
| | | /// <summary> |
| | |
| | | } |
| | | } |
| | | |
| | | #region 客户根据分类获取最大客户编码 |
| | | [Route("Gy_Supplier/getMaxNum")] |
| | | [HttpGet] |
| | | public object getMaxNum(int HSupTypeID, string user, string Organization) |
| | | { |
| | | try |
| | | { |
| | | List<object> columnNameList = new List<object>(); |
| | | //编辑权限 |
| | | if (!DBUtility.ClsPub.Security_Log_second("Gy_Supplier", 1, false, user)) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "无查看权限!"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | if (HSupTypeID == 0) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "没有选择具体分类!"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | else |
| | | { |
| | | ds = oCN.RunProcReturn(@"select * from h_v_Gy_SupplierList where 组织名称='" + Organization + "'" + "and HSupTypeID = '" + HSupTypeID + "'" + " order by 供应商代码 desc", "h_v_Gy_SupplierList"); |
| | | if (ds == null || ds.Tables[0].Rows.Count == 0) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 1; |
| | | objJsonResult.Message = "没有找到该分类的客户编码请使用普通新增"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | string HNumber = ds.Tables[0].Rows[0]["供应商代码"].ToString(); |
| | | // 使用正则表达式找到数字部分 (?<=\D)是一个零宽断言,表示前面的字符不是数字 (\d+)$表示后面跟着一连串字符串知道末尾 |
| | | Match match = Regex.Match(HNumber, @"(?<=\D)(\d+)$"); |
| | | if (match.Success) |
| | | { |
| | | string prefix = HNumber.Substring(0, HNumber.Length - match.Length); // 提取前缀 |
| | | int number = int.Parse(match.Value); // 解析数字 |
| | | // 数字+1 |
| | | number++; |
| | | // 格式化数字,保持原长度 |
| | | string formattedNumber = number.ToString().PadLeft(match.Length, '0'); |
| | | // 重新组合字符串 |
| | | string result = prefix + formattedNumber; |
| | | |
| | | objJsonResult.code = "1"; |
| | | objJsonResult.count = 1; |
| | | objJsonResult.Message = "success"; |
| | | objJsonResult.data = result; |
| | | return objJsonResult; |
| | | } |
| | | else |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 1; |
| | | objJsonResult.Message = "此分类供应商编码格式有误"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "Exception!" + e.ToString(); |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | #endregion |
| | | |
| | | /// <summary> |
| | | /// 供应商列表修改按钮方法 |
| | | ///参数:string sql。 |
| | |
| | | { |
| | | try |
| | | { |
| | | string sql = string.Format(@"select s.HItemID,s.HNumber 编码,s.HName 名称,s.HHelpCode 助记码,s.HShortName 简称,s.HAddress 地址,s.HLinkMan 联系人,s.HLinkPhone 联系电话 |
| | | ,s.HMobilePhone 手机,s.HFax 传真,s.HPostalCode 邮编,s.HEmail 电子邮件,s.HCorMan 法人代表,s.HBank 开户银行,s.HBankAccount 银行账号, |
| | | s.HTaxNum 税务登记号,s.HEnglishName 英文名称,s.HEngLishAddress 英文地址,s.HCountry 国家,s.HStopflag 禁用标志 |
| | | ,s.HRemark 备注,s.HAreaID 地区ID,a.HName 地区名称,s.HTaxRate 增值税率,s.HCurID 默认货币ID,r.HName 默认货币, |
| | | s.HSSID 结算方式ID,e.HName 结算方式 from Gy_Supplier s |
| | | left join Gy_AreaSet a on s.HAreaID=a.HItemID |
| | | left join Gy_Currency r on s.HCurID=r.HItemID |
| | | left join Gy_SettleStyle e on s.HSSID=e.HItemID |
| | | where s.HItemID='" + HInterID + "'"); |
| | | ds = oCN.RunProcReturn(sql, "Gy_Supplier"); |
| | | |
| | | string sql = string.Format(@"select * from h_v_Gy_SupplierEdit where HItemID='" + HInterID + "'"); |
| | | ds = oCN.RunProcReturn(sql, "h_v_Gy_SupplierEdit"); |
| | | DataSet cs = oCN.RunProcReturn("select * from Gy_Supplier_PayPlan where HSupID = '"+ HInterID + "'", "Gy_Supplier_PayPlan"); |
| | | DataSet cs1 = oCN.RunProcReturn("select * from Gy_Supplier_Link where HSupID = '" + HInterID + "'", "Gy_Supplier_Link"); |
| | | List<Object> list = new List<object>(); |
| | | list.Add(cs); |
| | | list.Add(cs1); |
| | | objJsonResult.code = "1"; |
| | | objJsonResult.count = 1; |
| | | objJsonResult.Message = ""; |
| | | objJsonResult.data = ds.Tables[0]; |
| | | objJsonResult.list = list; |
| | | return objJsonResult; |
| | | } |
| | | catch (Exception e) |
| | |
| | | { |
| | | var _value = oMain["oMain"].ToString(); |
| | | string msg1 = _value.ToString(); |
| | | //反序列化 |
| | | msg1 = "[" + msg1.ToString() + "]"; |
| | | string[] sArray = msg1.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries); |
| | | string msg2 = sArray[0].ToString(); //主表数据 |
| | | string msg3 = sArray[1].ToString(); //子表数据 |
| | | string msg4 = sArray[2].ToString(); //子表数据 |
| | | //主表反序列化 |
| | | msg2 = "[" + msg2.ToString() + "]"; |
| | | |
| | | DAL.ClsGy_Supplier_Ctl oDept = new DAL.ClsGy_Supplier_Ctl(); |
| | | DAL.ClsGy_Supplier_View oDeptHlp = new DAL.ClsGy_Supplier_View(); |
| | | |
| | | |
| | | |
| | | List<Supplier> list = Newtonsoft.Json.JsonConvert.DeserializeObject<List<Supplier>>(msg1); |
| | | List<Supplier> list = Newtonsoft.Json.JsonConvert.DeserializeObject<List<Supplier>>(msg2); |
| | | |
| | | long HItemID = list[0].HInterID; |
| | | string HNumber = list[0].HNumber; |
| | |
| | | string HAddress = list[0].HAddress; |
| | | string HLinkMan = list[0].HLinkMan; |
| | | string HLinkPhone = list[0].HLinkPhone; |
| | | string HBankAccount = list[0].HMobilePhone; |
| | | string HBankAccount = list[0].HBankAccount; |
| | | string HFax = list[0].HFax; |
| | | string HPostalCode = list[0].HPostalCode; |
| | | string HEmail = list[0].HEmail; |
| | |
| | | long HCreateOrgID = list[0].HCreateOrgID; |
| | | long HUseOrgID = list[0].HUseOrgID; |
| | | string HRemark = list[0].HRemark; |
| | | |
| | | string HMaterClass = list[0].HMaterClass; |
| | | long HPSStyleID = list[0].HPSStyleID; |
| | | long HSupTypeID = list[0].HSupTypeID; |
| | | |
| | | if (!DBUtility.ClsPub.AllowNumber(HNumber)) |
| | | { |
| | |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | |
| | | |
| | | |
| | | //若MAINDI重复则重新获取 |
| | | oCN.BeginTran(); |
| | | //主表 |
| | |
| | | ",HShortName,HAddress,HLinkMan,HLinkPhone,HMobilePhone" + |
| | | ",HFax,HPostalCode,HEmail,HBank,HBankAccount" + |
| | | ",HTaxNum,HTaxRate,HCountry,HCorMan,HEnglishName" + |
| | | ",HEnglishAddress,HCurID,HSSID,HAreaID) " + |
| | | ",HEnglishAddress,HCurID,HSSID,HAreaID,HMaterClass,HUSEORGID,HCREATEORGID,HPSStyleID,HSupTypeID) " + |
| | | " values('" + HNumber + "','" + HName + "','" + HHelpCode + "','" + HShortNumber + "','" + HParentID + "'" + |
| | | "," + HLevel + ",0,'" + HStopflag + "','" + HRemark + "'" + |
| | | "," + HLevel + ",1,'" + HStopflag + "','" + HRemark + "'" + |
| | | ",'" + HShortName + "','" + HAddress + "','" + HLinkMan + "','" + HLinkPhone + "','" + HMobilePhone + "'" + |
| | | ",'" + HFax + "','" + HPostalCode + "','" + HEmail + "','" + HBank + "','" + HBankAccount + "'" + |
| | | ",'" + HTaxNum + "','" + HTaxRate + "','" + HCountry + "','" + HCorMan + "','" + HEnglishName + "'" + |
| | | ",'" + HEnglishAddress + "'," + HCurID + "," + HSSID + "," + HAreaID + |
| | | ") "); |
| | | ",'" + HEnglishAddress + "'," + HCurID + "," + HSSID + "," + HAreaID +" ,'" + HMaterClass + " ','" + HUseOrgID + "' ,'" + HCreateOrgID + "' ,'" + HPSStyleID+ "' ,'" + HSupTypeID + |
| | | "') "); |
| | | //修改上级为非末级代码 |
| | | oCN.RunProc("Update Gy_Supplier set HEndflag=0 where HItemID=" + HParentID, ref DBUtility.ClsPub.sExeReturnInfo); |
| | | |
| | | //删除子表操作 防止出错 |
| | | DataSet Cs; |
| | | Cs = oCN.RunProcReturn("select MAX(HItemID)HItemID from Gy_Supplier", "Gy_Supplier"); |
| | | string MaxHItemID = Cs.Tables[0].Rows[0]["HItemID"].ToString(); |
| | | oCN.RunProc("delete from Gy_Supplier_PayPlan where HSupID='" + MaxHItemID + "'"); |
| | | oCN.RunProc("delete from Gy_Supplier_Link where HSupID='" + MaxHItemID + "'"); |
| | | |
| | | //子表添加 |
| | | List<ClsGy_Supplier_PayPlan> DetailColl = Newtonsoft.Json.JsonConvert.DeserializeObject<List<ClsGy_Supplier_PayPlan>>(msg3); |
| | | int i = 0; |
| | | foreach (ClsGy_Supplier_PayPlan oSub in DetailColl) |
| | | { |
| | | i++; |
| | | oCN.RunProc($@"Insert into Gy_Supplier_PayPlan |
| | | (HSupID,HSubID,HPayType,HPayRate,HPayTime,HPayRemark) |
| | | values({MaxHItemID},{i} ,'{oSub.HPayType}',{oSub.HPayRate},{oSub.HPayTime},'{oSub.HPayRemark}')"); |
| | | } |
| | | |
| | | //子表添加 |
| | | List<ClsGy_Supplier_Link> DetailCol2 = Newtonsoft.Json.JsonConvert.DeserializeObject<List<ClsGy_Supplier_Link>>(msg4); |
| | | int i2 = 0; |
| | | foreach (ClsGy_Supplier_Link oSub in DetailCol2) |
| | | { |
| | | i2++; |
| | | oCN.RunProc($@"Insert into Gy_Supplier_Link |
| | | (HSupID,HSubID,HLinkMan,HLinkPhone,HRemark) |
| | | values({MaxHItemID},{i2} ,'{oSub.HLinkMan}','{oSub.HLinkPhone}','{oSub.HRemark}')"); |
| | | } |
| | | |
| | | oCN.Commit(); |
| | | objJsonResult.code = "1"; |
| | | objJsonResult.count = 1; |
| | |
| | | string sql = string.Empty; |
| | | //保存 |
| | | oCN.BeginTran(); |
| | | sql = $"delete Gy_Supplier where HItemID = {lsmain[0].HItemID}"; |
| | | sql = $"delete from Gy_Supplier where HItemID = {lsmain[0].HItemID}"; |
| | | oCN.RunProc(sql); |
| | | sql = "set identity_insert Gy_Supplier on"; |
| | | oCN.RunProc(sql); |
| | |
| | | ",HShortName,HAddress,HLinkMan,HLinkPhone,HMobilePhone" + |
| | | ",HFax,HPostalCode,HEmail,HBank,HBankAccount" + |
| | | ",HTaxNum,HTaxRate,HCountry,HCorMan,HEnglishName" + |
| | | ",HEnglishAddress,HCurID,HSSID,HAreaID) " + |
| | | ",HEnglishAddress,HCurID,HSSID,HAreaID,HMaterClass,HERPItemID) " + |
| | | " values('" + lsmain[0].HItemID + "','" + lsmain[0].HNumber + "','" + lsmain[0].HName + "','" + lsmain[0].HHelpCode + "','" + lsmain[0].HShortNumber + "','" + lsmain[0].HParentID + "'" + |
| | | "," + lsmain[0].HLevel + ",0,'" + lsmain[0].HStopflag + "','" + lsmain[0].HRemark + "'" + |
| | | ",'" + lsmain[0].HShortName + "','" + lsmain[0].HAddress + "','" + lsmain[0].HLinkMan + "','" + lsmain[0].HLinkPhone + "','" + lsmain[0].HMobilePhone + "'" + |
| | | ",'" + lsmain[0].HFax + "','" + lsmain[0].HPostalCode + "','" + lsmain[0].HEmail + "','" + lsmain[0].HBank + "','" + lsmain[0].HBankAccount + "'" + |
| | | ",'" + lsmain[0].HTaxNum + "','" + lsmain[0].HTaxRate + "','" + lsmain[0].HCountry + "','" + lsmain[0].HCorMan + "','" + lsmain[0].HEnglishName + "'" + |
| | | ",'" + lsmain[0].HEnglishAddress + "'," + lsmain[0].HCurID + "," + lsmain[0].HSSID + "," + lsmain[0].HAreaID + |
| | | ",'" + lsmain[0].HEnglishAddress + "'," + lsmain[0].HCurID + "," + lsmain[0].HSSID + "," + lsmain[0].HAreaID +",'"+lsmain[0].HMaterClass+ |
| | | "'," + lsmain[0].HItemID + |
| | | ") "); |
| | | //修改上级为非末级代码 |
| | | sql = "set identity_insert Gy_Supplier off"; |
| | |
| | | ///参数:string sql。 |
| | | ///返回值:object。 |
| | | /// </summary> |
| | | |
| | | [Route("Gy_Supplier/AddBill1")] |
| | | [HttpPost] |
| | | public object AddBill1([FromBody] JObject oMain) |
| | |
| | | string msg1 = _value.ToString(); |
| | | string[] sArray = msg1.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries); |
| | | string msg2 = sArray[0].ToString(); //表头数据 |
| | | string msg3 = sArray[1].ToString(); //列表主ID |
| | | string msg4 = sArray[2].ToString(); //登录人员 |
| | | string msg5 = sArray[3].ToString(); //权限模块代码 |
| | | string msg3 = sArray[1].ToString(); //子表数据-付款计划 |
| | | string msg4 = sArray[2].ToString(); //列表主ID |
| | | string msg5 = sArray[3].ToString(); //登录人员 |
| | | string msg6 = sArray[4].ToString(); //权限模块代码 |
| | | string msg7 = sArray[5].ToString(); //子表数据-联系人 |
| | | //反序列化 |
| | | msg2 = "[" + msg2.ToString() + "]"; |
| | | List<Supplier> list = Newtonsoft.Json.JsonConvert.DeserializeObject<List<Supplier>>(msg2); |
| | |
| | | string HAddress = list[0].HAddress; |
| | | string HLinkMan = list[0].HLinkMan; |
| | | string HLinkPhone = list[0].HLinkPhone; |
| | | string HBankAccount = list[0].HMobilePhone; |
| | | string HBankAccount = list[0].HBankAccount; |
| | | string HFax = list[0].HFax; |
| | | string HPostalCode = list[0].HPostalCode; |
| | | string HEmail = list[0].HEmail; |
| | |
| | | long HCreateOrgID = list[0].HCreateOrgID; |
| | | long HUseOrgID = list[0].HUseOrgID; |
| | | string HRemark = list[0].HRemark; |
| | | |
| | | string HMaterClass = list[0].HMaterClass; |
| | | long HPSStyleID = list[0].HPSStyleID; |
| | | long HSupTypeID = list[0].HSupTypeID; |
| | | |
| | | //判断权限 |
| | | if (!ClsPub.Security_Log(msg5, 1, false, msg4)) |
| | | if (!ClsPub.Security_Log(msg6, 1, false, msg5)) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | |
| | | ",HEnglishAddress='" + HEnglishAddress + "'" + |
| | | ",HCurID=" + HCurID.ToString() + |
| | | ",HSSID=" + HSSID.ToString() + |
| | | ",HAreaID=" + HAreaID.ToString() + "Where HItemID=" + HItemID, ref DBUtility.ClsPub.sExeReturnInfo); |
| | | ",HMaterClass='" + HMaterClass + |
| | | "',HPSStyleID='"+ HPSStyleID.ToString() + |
| | | "',HSupTypeID='" + HSupTypeID.ToString() + |
| | | "',HUSEORGID='" + HUseOrgID.ToString() + |
| | | "',HCREATEORGID='" + HCreateOrgID.ToString() + |
| | | "',HAreaID=" + HAreaID.ToString() + "Where HItemID=" + HItemID, ref DBUtility.ClsPub.sExeReturnInfo); |
| | | |
| | | |
| | | //修改子项目代码 |
| | |
| | | //将上级 为非末级 |
| | | oCN.RunProc("Update Gy_Supplier set HEndflag=0 where HItemID=" + HParentID, ref DBUtility.ClsPub.sExeReturnInfo); |
| | | // |
| | | |
| | | //删除子表操作 防止出错 |
| | | oCN.RunProc("delete from Gy_Supplier_PayPlan where HSupID='" + HItemID + "'"); |
| | | oCN.RunProc("delete from Gy_Supplier_Link where HSupID='" + HItemID + "'"); |
| | | |
| | | //子表添加 |
| | | List<ClsGy_Supplier_PayPlan> DetailColl = Newtonsoft.Json.JsonConvert.DeserializeObject<List<ClsGy_Supplier_PayPlan>>(msg3); |
| | | int i = 0; |
| | | foreach (ClsGy_Supplier_PayPlan oSub in DetailColl) |
| | | { |
| | | i++; |
| | | oCN.RunProc($@"Insert into Gy_Supplier_PayPlan |
| | | (HSupID,HSubID,HPayType,HPayRate,HPayTime,HPayRemark) |
| | | values({HItemID},{i} ,'{oSub.HPayType}',{oSub.HPayRate},{oSub.HPayTime},'{oSub.HPayRemark}')"); |
| | | } |
| | | |
| | | //子表添加 |
| | | List<ClsGy_Supplier_Link> DetailCol2 = Newtonsoft.Json.JsonConvert.DeserializeObject<List<ClsGy_Supplier_Link>>(msg7); |
| | | int i2 = 0; |
| | | foreach (ClsGy_Supplier_Link oSub in DetailCol2) |
| | | { |
| | | i2++; |
| | | oCN.RunProc($@"Insert into Gy_Supplier_Link |
| | | (HSupID,HSubID,HLinkMan,HLinkPhone,HRemark) |
| | | values({HItemID},{i2} ,'{oSub.HLinkMan}','{oSub.HLinkPhone}','{oSub.HRemark}')"); |
| | | } |
| | | |
| | | |
| | | |
| | | oCN.Commit(); |
| | | objJsonResult.code = "1"; |
| | | objJsonResult.count = 1; |
| | |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | |
| | | //删除前控制========================================= |
| | | string sql1 = "exec h_p_Gy_Supplier_BeforeDelCtrl " + HItemID + ",'" + User + "'"; |
| | | ds = oCN.RunProcReturn(sql1, "h_p_Gy_Supplier_BeforeDelCtrl"); |
| | | if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 1; |
| | | objJsonResult.Message = "删除失败!原因:删除前判断失败,请与网络管理人员联系"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | |
| | | if (ds.Tables[0].Rows[0]["HBack"].ToString() != "0") |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 1; |
| | | objJsonResult.Message = "删除失败!原因:" + ds.Tables[0].Rows[0]["HRemark"].ToString(); ; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | //================================================================================== |
| | | |
| | | oCN.BeginTran(); |
| | | // |
| | | if (oGroup.DeleteByID(HItemID)) |
| | | { |
| | | //删除子表 |
| | | oCN.RunProc("delete from Gy_Supplier_PayPlan where HSupID='" + HItemID + "'"); |
| | | oCN.RunProc("delete from Gy_Supplier_Link where HSupID='" + HItemID + "'"); |
| | | oCN.Commit(); |
| | | //写入日志 |
| | | ClsPub.Add_Log("", "删除项目,代码:" + oGroupHlp.omodel.HNumber + ",名称:" + oGroupHlp.omodel.HName, ClsPub.CurUserName); |
| | | //更新上级为 末级 |
| | |
| | | } |
| | | else |
| | | { |
| | | oCN.Commit(); |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "删除失败"; |
| | |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | |
| | | |
| | | #region 供应商审核、反审核 |
| | | /// <summary> |
| | | /// |
| | | /// </summary> |
| | | /// <param name="HInterID">单据ID</param> |
| | | /// <param name="IsAudit">审核(0),反审核(1)</param> |
| | | /// <param name="CurUserName">审核人</param> |
| | | /// <returns></returns> |
| | | [Route("Gy_Supplier/AuditGy_Supplier")] |
| | | [HttpGet] |
| | | public object AuditGy_Material(int HInterID, int IsAudit, string CurUserName) |
| | | { |
| | | try |
| | | { |
| | | //审核权限 |
| | | if (!DBUtility.ClsPub.Security_Log_second("Gy_Supplier_Check", 1, false, CurUserName)) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "审核失败!无权限!"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | |
| | | var ds = oCN.RunProcReturn("select * from Gy_Supplier where HItemID=" + HInterID, "Gy_Supplier"); |
| | | if (ds.Tables[0].Rows.Count > 0) |
| | | { |
| | | if (IsAudit == 0) //审核判断 |
| | | { |
| | | if (ds.Tables[0].Rows[0]["HCheckEmp"].ToString() != "") |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "单据已审核!不能再次审核!"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | if (IsAudit == 1) //反审核判断 |
| | | { |
| | | if (ds.Tables[0].Rows[0]["HCheckEmp"].ToString() == "") |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "单据未审核!不需要反审核!"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | } |
| | | else |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "单据不存在!"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | |
| | | oCN.BeginTran(); |
| | | |
| | | if (IsAudit == 0) //审核判断 |
| | | { |
| | | oCN.RunProc("update Gy_Supplier set HCheckEmp='" + CurUserName + "',HCheckTime=getdate() where HItemID=" + HInterID); |
| | | |
| | | objJsonResult.code = "1"; |
| | | objJsonResult.count = 1; |
| | | objJsonResult.Message = "审核成功"; |
| | | objJsonResult.data = null; |
| | | } |
| | | if (IsAudit == 1) //反审核判断 |
| | | { |
| | | oCN.RunProc("update Gy_Supplier set HCheckEmp='',HCheckTime=null where HItemID=" + HInterID); |
| | | |
| | | objJsonResult.code = "1"; |
| | | objJsonResult.count = 1; |
| | | objJsonResult.Message = "反审核成功"; |
| | | objJsonResult.data = null; |
| | | } |
| | | oCN.Commit(); |
| | | |
| | | return objJsonResult; |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | oCN.RollBack(); |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "审核失败或者反审核失败!" + e.ToString(); |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | #endregion |
| | | |
| | | #region 供应商禁用、反禁用 |
| | | /// <summary> |
| | | /// |
| | | /// </summary> |
| | | /// <param name="HInterID">单据ID</param> |
| | | /// <param name="IsStop">禁用(0),反禁用(1)</param> |
| | | /// <param name="CurUserName">审核人</param> |
| | | /// <returns></returns> |
| | | [Route("Gy_Supplier/StopGy_Supplier")] |
| | | [HttpGet] |
| | | public object StopGy_Supplier(int HInterID, int IsStop, string CurUserName) |
| | | { |
| | | try |
| | | { |
| | | //审核权限 |
| | | if (!DBUtility.ClsPub.Security_Log_second("Gy_Supplier_Stop", 1, false, CurUserName)) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "禁用失败!无权限!"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | |
| | | var ds = oCN.RunProcReturn("select * from Gy_Supplier where HItemID=" + HInterID, "Gy_Supplier"); |
| | | if (ds.Tables[0].Rows.Count > 0) |
| | | { |
| | | if (IsStop == 0) //禁用判断 |
| | | { |
| | | if (ds.Tables[0].Rows[0]["HStopEmp"].ToString() != "") |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "单据已禁用!不能再次禁用!"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | if (IsStop == 1) //反禁用判断 |
| | | { |
| | | if (ds.Tables[0].Rows[0]["HStopEmp"].ToString() == "") |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "单据未禁用!不需要反禁用!"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | } |
| | | else |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "单据不存在!"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | |
| | | oCN.BeginTran(); |
| | | |
| | | if (IsStop == 0) //禁用判断 |
| | | { |
| | | oCN.RunProc("update Gy_Supplier set HStopEmp='" + CurUserName + "',HStopTime=getdate(),HStopflag=1 where HItemID=" + HInterID); |
| | | |
| | | objJsonResult.code = "1"; |
| | | objJsonResult.count = 1; |
| | | objJsonResult.Message = "禁用成功"; |
| | | objJsonResult.data = null; |
| | | } |
| | | if (IsStop == 1) //反禁用判断 |
| | | { |
| | | oCN.RunProc("update Gy_Supplier set HStopEmp='',HStopTime=null,HStopflag=0 where HItemID=" + HInterID); |
| | | |
| | | objJsonResult.code = "1"; |
| | | objJsonResult.count = 1; |
| | | objJsonResult.Message = "反禁用成功"; |
| | | objJsonResult.data = null; |
| | | } |
| | | oCN.Commit(); |
| | | |
| | | return objJsonResult; |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | oCN.RollBack(); |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "禁用失败或者反禁用失败!" + e.ToString(); |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | #endregion |
| | | |
| | | #region [同步基础资料] |
| | | [Route("Gy_Supplier/Gy_SupplierViewApi")] |
| | |
| | | ,HPAYCONDITION |
| | | ) |
| | | values |
| | | ({jsonData.HItemID},{jsonData.HERPItemID},'{jsonData.HNumber}','{jsonData.HName}', |
| | | ({jsonData.HItemID},{jsonData.HItemID},'{jsonData.HNumber}','{jsonData.HName}', |
| | | '{jsonData.HShortNumber}',{jsonData.HParentID},{jsonData.HLevel},{jsonData.HEndFlag},{jsonData.HStopflag},'{jsonData.HRemark}','{jsonData.HUseFlag}','{jsonData.HMakeTime}',{jsonData.HCREATEORGID},{jsonData.HUSEORGID},{jsonData.HPAYCONDITION})"; |
| | | |
| | | oCN.RunProc(sql); |
| | |
| | | } |
| | | #endregion |
| | | |
| | | #region 根据父id和等级获得树状图递归 |
| | | |
| | | [Route("Gy_BadReason/Gy_SupTypeTreeListByLevel")] |
| | | [HttpGet] |
| | | public object Gy_MaterTypeTreeListByLevel() |
| | | { |
| | | try |
| | | { |
| | | string sql1 = string.Format("select hitemid,hnumber,hname,hparentid,hlevel from Gy_SupType order by hnumber"); |
| | | |
| | | ds = oCN.RunProcReturn(sql1, "Gy_SupType"); |
| | | |
| | | List<TreeModel> treeModels = new List<TreeModel>(); |
| | | TreeModel first = new TreeModel(); |
| | | first.id = "0"; |
| | | first.title = "供应商分类设置"; |
| | | treeModels.Add(first); |
| | | |
| | | foreach (DataRow row in ds.Tables[0].Rows) |
| | | { |
| | | var HLevel = (int)row["hlevel"]; |
| | | if (HLevel == 1) |
| | | { |
| | | TreeModel tree = new TreeModel(); |
| | | tree.id = row["hitemid"].ToString(); |
| | | tree.title = row["hname"].ToString(); |
| | | treeModels[0].children.Add(tree); |
| | | } |
| | | } |
| | | getTreeByLevel(ds.Tables[0], treeModels[0].children, 2); |
| | | |
| | | objJsonResult.code = "1"; |
| | | objJsonResult.count = 1; |
| | | objJsonResult.Message = "Sucess!"; |
| | | objJsonResult.data = Newtonsoft.Json.JsonConvert.SerializeObject(treeModels); |
| | | return objJsonResult; |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "Exception!" + e.ToString(); |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | |
| | | public void getTreeByLevel(DataTable dt, List<TreeModel> tree, int num) |
| | | { |
| | | for (int m = 0; m < tree.Count; m++) |
| | | { |
| | | tree[m].children = new List<TreeModel>(); |
| | | for (int i = 0; i < dt.Rows.Count; i++)//第一次循环,得到所有根节点的子集 |
| | | { |
| | | var HLevel = (int)dt.Rows[i]["hlevel"]; |
| | | var HParentID = dt.Rows[i]["hparentid"].ToString(); |
| | | if (HLevel == num && HParentID == tree[m].id) |
| | | { |
| | | TreeModel tbjson = new TreeModel(); |
| | | tbjson.id = dt.Rows[i]["hitemid"].ToString(); |
| | | tbjson.title = dt.Rows[i]["hname"].ToString(); |
| | | tree[m].children.Add(tbjson); |
| | | } |
| | | } |
| | | for (int i = 0; i < tree[m].children.Count; i++) |
| | | { |
| | | getTreeByLevel(dt, tree[m].children, num + 1);//再次用子集去循环,拿出子集的子集 |
| | | } |
| | | } |
| | | |
| | | } |
| | | #endregion |
| | | |
| | | #region 物料分类 树形图(根据代码展开树状图) |
| | | public class TreeModel |
| | | { |
| | | public string id { get; set; } |
| | | public string title { get; set; } |
| | | public List<TreeModel> children = new List<TreeModel>(); |
| | | } |
| | | /// <summary> |
| | | /// 递归函数 |
| | | /// </summary> |
| | | public void digui(DataTable dt, List<TreeModel> tree, int num) |
| | | { |
| | | for (int m = 0; m < tree.Count; m++) |
| | | { |
| | | tree[m].children = new List<TreeModel>(); |
| | | for (int i = 0; i < dt.Rows.Count; i++)//第一次循环,得到所有根节点的子集 |
| | | { |
| | | var strLen = dt.Rows[i]["hnumber"].ToString().Split('.'); |
| | | if (strLen.Length == num && dt.Rows[i]["hnumber"].ToString().Contains(tree[m].id + ".")) |
| | | { |
| | | TreeModel tbjson = new TreeModel(); |
| | | tbjson.id = dt.Rows[i]["hitemid"].ToString(); |
| | | tbjson.title = dt.Rows[i]["hname"].ToString(); |
| | | tree[m].children.Add(tbjson); |
| | | } |
| | | } |
| | | var strLens = tree[m].id.Split('.'); |
| | | for (int i = 0; i < tree[m].children.Count; i++) |
| | | { |
| | | digui(dt, tree[m].children, strLens.Length + 2);//再次用子集去循环,拿出子集的子集 |
| | | } |
| | | } |
| | | |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region 供应商 文件导入保存 |
| | | #region 供应商 文件上传 |
| | | [Route("Gy_Supplier/Gy_Supplier_Excel")] |
| | | [HttpPost] |
| | | public object Gy_Supplier_Excel() |
| | | { |
| | | try |
| | | { |
| | | //获取文件名称 |
| | | var file = HttpContext.Current.Request.Files[0]; |
| | | //获取文件物理路径 |
| | | string ExcelPath = HttpContext.Current.Server.MapPath("~/" + file.FileName); |
| | | //保存文件 |
| | | file.SaveAs(ExcelPath); |
| | | |
| | | NpoiHelper np = new NpoiHelper(); |
| | | DataSet ExcelDs = np.ReadExcel(ExcelPath, 1, 1, "0"); |
| | | |
| | | //删除文件 |
| | | File.Delete(ExcelPath); |
| | | |
| | | //创建临时表 |
| | | DataTable tb2 = new DataTable("dt2"); |
| | | |
| | | //添加列名 |
| | | for (int i = 0; i < ExcelDs.Tables[0].Columns.Count; i++) |
| | | { |
| | | tb2.Columns.Add(ExcelDs.Tables[0].Rows[0][i].ToString()); |
| | | } |
| | | //模板缺少列 但需要从数据库中查询出来显示在页面的字段 |
| | | tb2.Columns.Add("HOrgID", typeof(Int32));//组织ID |
| | | tb2.Columns.Add("HCurID", typeof(Int32));//币别ID |
| | | tb2.Columns.Add("HSSID", typeof(Int32));//结算方式ID |
| | | tb2.Columns.Add("HAreaID", typeof(Int32));//地区ID |
| | | //添加数据 |
| | | for (int i = 1; i < ExcelDs.Tables[0].Rows.Count; i++) |
| | | { |
| | | DataRow row = tb2.NewRow(); |
| | | for (int j = 0; j < ExcelDs.Tables[0].Columns.Count; j++) |
| | | { |
| | | row[j] = ExcelDs.Tables[0].Rows[i][j].ToString(); |
| | | } |
| | | tb2.Rows.Add(row); |
| | | } |
| | | |
| | | |
| | | var error = ""; |
| | | |
| | | //查询没有的列 |
| | | if (!tb2.Columns.Contains("组织代码")) |
| | | error += "没有找到【组织代码】的标题,"; |
| | | |
| | | if (!tb2.Columns.Contains("组织名称")) |
| | | error += "没有找到【组织名称】的标题,"; |
| | | |
| | | if (!tb2.Columns.Contains("供应商代码")) |
| | | error += "没有找到【供应商代码】的标题,"; |
| | | |
| | | if (!tb2.Columns.Contains("供应商名称")) |
| | | error += "没有找到【供应商】的标题,"; |
| | | |
| | | |
| | | if (!tb2.Columns.Contains("简称")) |
| | | error += "没有找到【简称】的标题,"; |
| | | |
| | | if (!tb2.Columns.Contains("币别代码")) |
| | | error += "没有找到【币别代码】的标题,"; |
| | | |
| | | |
| | | if (!tb2.Columns.Contains("币别")) |
| | | error += "没有找到【币别】的标题,"; |
| | | |
| | | if (!tb2.Columns.Contains("结算方式代码")) |
| | | error += "没有找到【结算方式代码】的标题,"; |
| | | |
| | | |
| | | if (!tb2.Columns.Contains("结算方式")) |
| | | error += "没有找到【结算方式】的标题,"; |
| | | |
| | | if (!tb2.Columns.Contains("地区代码")) |
| | | error += "没有找到【地区代码】的标题,"; |
| | | |
| | | |
| | | if (!tb2.Columns.Contains("所属地区")) |
| | | error += "没有找到【所属地区】的标题,"; |
| | | |
| | | if (!tb2.Columns.Contains("地址")) |
| | | error += "没有找到【地址】的标题,"; |
| | | |
| | | if (!tb2.Columns.Contains("电子邮箱")) |
| | | error += "没有找到【电子邮箱】的标题,"; |
| | | |
| | | if (!tb2.Columns.Contains("银行")) |
| | | error += "没有找到【银行】的标题,"; |
| | | |
| | | if (!tb2.Columns.Contains("银行账户")) |
| | | error += "没有找到【银行账户】的标题,"; |
| | | |
| | | if (!tb2.Columns.Contains("税务登记号")) |
| | | error += "没有找到【税务登记号】的标题,"; |
| | | |
| | | if (!tb2.Columns.Contains("邮编")) |
| | | error += "没有找到【邮编】的标题,"; |
| | | |
| | | if (!tb2.Columns.Contains("国家")) |
| | | error += "没有找到【国家】的标题,"; |
| | | |
| | | if (!tb2.Columns.Contains("法人代表")) |
| | | error += "没有找到【法人代表】的标题,"; |
| | | |
| | | if (!tb2.Columns.Contains("英文名称")) |
| | | error += "没有找到【英文名称】的标题,"; |
| | | |
| | | if (!tb2.Columns.Contains("英文地址")) |
| | | error += "没有找到【英文地址】的标题,"; |
| | | |
| | | if (!tb2.Columns.Contains("助记码")) |
| | | error += "没有找到【助记码】的标题,"; |
| | | |
| | | if (!tb2.Columns.Contains("备注")) |
| | | error += "没有找到【备注】的标题,"; |
| | | |
| | | if (error.Length > 0) |
| | | { |
| | | objJsonResult.code = CodeConstant.FAIL; |
| | | objJsonResult.count = CountConstant.FAIL; |
| | | objJsonResult.Message = $"Excel模板存在错误,{error}\r\n"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | |
| | | for (int i = 0; i <= tb2.Rows.Count - 1; i++) |
| | | { |
| | | string HName = ""; |
| | | string HNum = ""; |
| | | string HORGNumber = ""; |
| | | string HORGName = ""; |
| | | string HCurNumber = ""; |
| | | string HCurName = ""; |
| | | string HSSNumber = ""; |
| | | string HSSName = ""; |
| | | string HAreaNumber = ""; |
| | | string HAreaName = ""; |
| | | |
| | | HName = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["供应商名称"].ToString()); |
| | | HNum = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["供应商代码"].ToString()); |
| | | HORGNumber = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["组织代码"].ToString()); |
| | | HORGName = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["组织名称"].ToString()); |
| | | HCurNumber = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["币别代码"].ToString()); |
| | | HCurName = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["币别"].ToString()); |
| | | HSSNumber = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["结算方式代码"].ToString()); |
| | | HSSName = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["结算方式"].ToString()); |
| | | HAreaNumber = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["地区代码"].ToString()); |
| | | HAreaName = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["所属地区"].ToString()); |
| | | |
| | | //检查物料 |
| | | int index = i + 1; |
| | | |
| | | if (HORGNumber != "") |
| | | { |
| | | |
| | | //查询组织 |
| | | ds = oCN.RunProcReturn("select * from Xt_ORGANIZATIONS where HNumber='" + HORGNumber + "' and Hname='" + HORGName + "'", "Xt_ORGANIZATIONS"); |
| | | |
| | | if (ds.Tables[0].Rows.Count == 0) |
| | | { |
| | | objJsonResult.code = CodeConstant.FAIL; |
| | | objJsonResult.count = CountConstant.FAIL; |
| | | objJsonResult.Message = "第" + index + "行,组织不存在!"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | else |
| | | { |
| | | tb2.Rows[i]["HOrgID"] = ds.Tables[0].Rows[0]["HItemID"].ToString(); |
| | | } |
| | | |
| | | if (HCurNumber != "") |
| | | { |
| | | //查询币别 |
| | | ds = oCN.RunProcReturn("select * from Gy_Currency where HNumber='" + HCurNumber + "' and Hname='" + HCurName + "'", "Gy_Currency"); |
| | | |
| | | if (ds.Tables[0].Rows.Count == 0) |
| | | { |
| | | objJsonResult.code = CodeConstant.FAIL; |
| | | objJsonResult.count = CountConstant.FAIL; |
| | | objJsonResult.Message = "第" + index + "行,币别不存在!"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | else |
| | | { |
| | | tb2.Rows[i]["HCurID"] = ds.Tables[0].Rows[0]["HItemID"].ToString(); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | tb2.Rows[i]["HCurID"] = 0; |
| | | } |
| | | |
| | | if (HSSNumber != "") |
| | | { |
| | | //查询结算方式 |
| | | ds = oCN.RunProcReturn("select * from Gy_SettleStyle where HNumber='" + HSSNumber + "' and Hname='" + HSSName + "'", "Gy_SettleStyle"); |
| | | |
| | | if (ds.Tables[0].Rows.Count == 0) |
| | | { |
| | | objJsonResult.code = CodeConstant.FAIL; |
| | | objJsonResult.count = CountConstant.FAIL; |
| | | objJsonResult.Message = "第" + index + "行,币别不存在!"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | else |
| | | { |
| | | tb2.Rows[i]["HSSID"] = ds.Tables[0].Rows[0]["HItemID"].ToString(); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | tb2.Rows[i]["HSSID"] = 0; |
| | | } |
| | | if (HAreaNumber != "") |
| | | { |
| | | //查询地区 |
| | | ds = oCN.RunProcReturn("select * from Gy_AreaSet where HNumber='" + HAreaNumber + "' and Hname='" + HAreaName + "'", "Gy_AreaSet"); |
| | | |
| | | if (ds.Tables[0].Rows.Count == 0) |
| | | { |
| | | objJsonResult.code = CodeConstant.FAIL; |
| | | objJsonResult.count = CountConstant.FAIL; |
| | | objJsonResult.Message = "第" + index + "行,地区不存在!"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | else |
| | | { |
| | | tb2.Rows[i]["HAreaID"] = ds.Tables[0].Rows[0]["HItemID"].ToString(); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | tb2.Rows[i]["HAreaID"] = 0; |
| | | } |
| | | |
| | | //供应商名称 |
| | | if (HName == "") |
| | | { |
| | | objJsonResult.code = CodeConstant.FAIL; |
| | | objJsonResult.count = CountConstant.FAIL; |
| | | objJsonResult.Message = "第" + index + "行,供应商名称不能为空!"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | |
| | | //供应商代码 |
| | | if (HNum == "") |
| | | { |
| | | objJsonResult.code = CodeConstant.FAIL; |
| | | objJsonResult.count = CountConstant.FAIL; |
| | | objJsonResult.Message = "第" + index + "行,供应商代码不能为空!"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | else |
| | | { |
| | | objJsonResult.code = CodeConstant.FAIL; |
| | | objJsonResult.count = CountConstant.FAIL; |
| | | objJsonResult.Message = "第" + index + "行,组织代码为空"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | |
| | | objJsonResult.code = CodeConstant.SUCCEED; |
| | | objJsonResult.count = CountConstant.SUCCEED; |
| | | objJsonResult.Message = error; |
| | | objJsonResult.data = tb2; |
| | | return objJsonResult; |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | objJsonResult.code = CodeConstant.FAIL; |
| | | objJsonResult.count = CountConstant.FAIL; |
| | | objJsonResult.Message = "Exception!" + e.ToString(); |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | #endregion |
| | | |
| | | #region 供应商项目 导入(保存) |
| | | [Route("Gy_Supplier/Gy_Supplier_btnSave")] |
| | | [HttpPost] |
| | | public object Gy_Supplier_btnSave([FromBody] JObject sMainSub) |
| | | { |
| | | var _value = sMainSub["sMainSub"].ToString(); |
| | | string msg1 = _value.ToString(); |
| | | string[] sArray = msg1.Split(new string[] { "&和" }, StringSplitOptions.RemoveEmptyEntries); |
| | | string msg2 = sArray[0].ToString(); |
| | | string user = sArray[1].ToString(); |
| | | try |
| | | { |
| | | if (!DBUtility.ClsPub.Security_Log("Gy_Supplier_Edit", 1, false, user)) |
| | | { |
| | | objJsonResult.code = CodeConstant.FAIL; |
| | | objJsonResult.count = CountConstant.FAIL; |
| | | objJsonResult.Message = "无保存权限!"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | |
| | | List<object> Excel = Newtonsoft.Json.JsonConvert.DeserializeObject<List<object>>(msg2); |
| | | List<Dictionary<string, string>> list = new List<Dictionary<string, string>>(); |
| | | |
| | | foreach (JObject item in Excel) |
| | | { |
| | | Dictionary<string, string> dic = new Dictionary<string, string>(); |
| | | foreach (var itm in item.Properties()) |
| | | { |
| | | dic.Add(itm.Name, itm.Value.ToString()); |
| | | } |
| | | list.Add(dic); |
| | | } |
| | | |
| | | oCN.BeginTran(); |
| | | int i = 1; |
| | | foreach (Dictionary<string, string> item in list) |
| | | { |
| | | string HOrgID = item["HOrgID"].ToString();//组织ID |
| | | string HCurID = item["HCurID"].ToString();//币别ID |
| | | string HSSID = item["HSSID"].ToString();//结算方式ID |
| | | string HAreaID = item["HAreaID"].ToString();//地区ID |
| | | string HName = item["供应商名称"].ToString(); |
| | | string HNumber = item["供应商代码"].ToString(); |
| | | string HRemark = item["备注"].ToString(); |
| | | string HHelpCode = item["助记码"].ToString(); |
| | | string HShortNumber; |
| | | HShortNumber = DBUtility.ClsPub.GetShortNumber(HNumber);//短代码 |
| | | if (HShortNumber.Trim() == "") |
| | | { |
| | | objJsonResult.code = CodeConstant.FAIL; |
| | | objJsonResult.count = CountConstant.FAIL; |
| | | objJsonResult.Message = "保存失败!短代码为空!"; |
| | | objJsonResult.data = 1; |
| | | return objJsonResult; |
| | | } |
| | | int HLevel = DBUtility.ClsPub.GetLevel(HNumber); //等级 |
| | | int HParentID = 0;//父id |
| | | int HStopflag = 0;//禁用标记 |
| | | string HShortName = item["简称"].ToString(); |
| | | string HAddress = item["地址"].ToString(); |
| | | string HLinkMan = "";//联系人 |
| | | string HLinkPhone = "";//联系电话 |
| | | string HMobilePhone = "";//手机 |
| | | string HFax = "";//传真 |
| | | string HPostalCode = item["邮编"].ToString(); |
| | | string HEmail = item["电子邮箱"].ToString(); |
| | | string HBank = item["银行"].ToString(); |
| | | string HBankAccount = item["银行账户"].ToString(); |
| | | string HTaxNum = item["税务登记号"].ToString(); |
| | | string HCountry = item["国家"].ToString(); |
| | | string HCorMan = item["法人代表"].ToString(); |
| | | string HEnglishName = item["英文名称"].ToString(); |
| | | string HEnglishAddress = item["英文地址"].ToString(); |
| | | int HTaxRate = 13;//增值税率 |
| | | if (!DBUtility.ClsPub.AllowNumber(HNumber.Trim())) |
| | | { |
| | | objJsonResult.code = CodeConstant.FAIL; |
| | | objJsonResult.count = CountConstant.FAIL; |
| | | objJsonResult.Message = "保存失败!代码中不能出现连续‘.’并且首位末位不能为‘.’!"; |
| | | objJsonResult.data = 1; |
| | | return objJsonResult; |
| | | } |
| | | |
| | | ds = oCN.RunProcReturn("select * from Gy_Supplier where HNumber='" + HNumber + "'", "Gy_Supplier"); |
| | | |
| | | if (ds.Tables[0].Rows.Count == 0) |
| | | { |
| | | oCN.RunProc("Insert Into Gy_Supplier " + |
| | | "(HNumber,HName,HHelpCode,HShortNumber,HParentID" + |
| | | ",HLevel,HEndFlag,HStopflag,HRemark" + |
| | | ",HShortName,HAddress,HLinkMan,HLinkPhone,HMobilePhone" + |
| | | ",HFax,HPostalCode,HEmail,HBank,HBankAccount" + |
| | | ",HTaxNum,HTaxRate,HCountry,HCorMan,HEnglishName" + |
| | | ",HEnglishAddress,HCurID,HSSID,HAreaID,HMaterClass,HUSEORGID,HCREATEORGID,HPSStyleID,HSupTypeID) " + |
| | | " values('" + HNumber + "','" + HName + "','" + HHelpCode + "','" + HShortNumber + "','" + HParentID + "'" + |
| | | "," + HLevel + ",1,'" + HStopflag + "','" + HRemark + "'" + |
| | | ",'" + HShortName + "','" + HAddress + "','" + HLinkMan + "','" + HLinkPhone + "','" + HMobilePhone + "'" + |
| | | ",'" + HFax + "','" + HPostalCode + "','" + HEmail + "','" + HBank + "','" + HBankAccount + "'" + |
| | | ",'" + HTaxNum + "','" + HTaxRate + "','" + HCountry + "','" + HCorMan + "','" + HEnglishName + "'" + |
| | | ",'" + HEnglishAddress + "'," + HCurID + "," + HSSID + "," + HAreaID + " ,'" + 0 + " ','" + HOrgID + "' ,'" + HOrgID + "' ,'" + 0 + "' ,'" + 0 + |
| | | "') "); |
| | | } |
| | | else |
| | | { |
| | | //主表 |
| | | oCN.RunProc("Update Gy_Supplier set " + |
| | | "HName='" + HName + "'" + |
| | | ",HShortNumber='" + HShortNumber + "'" + |
| | | ",HParentID=" + HParentID.ToString() + |
| | | ",HLevel=" + HLevel.ToString() + |
| | | ",HStopflag ='" + HStopflag + "'" + |
| | | ",HRemark= '" + HRemark + "'" + |
| | | ",HHelpCode='" + HHelpCode + "'" + |
| | | ",HShortName='" + HShortName + "'" + |
| | | ",HAddress='" + HAddress + "'" + |
| | | ",HLinkMan='" + HLinkMan + "'" + |
| | | ",HLinkPhone='" + HLinkPhone + "'" + |
| | | ",HMobilePhone='" + HMobilePhone + "'" + |
| | | ",HFax='" + HFax + "'" + |
| | | ",HPostalCode='" + HPostalCode + "'" + |
| | | ",HEmail='" + HEmail + "'" + |
| | | ",HBank='" + HBank + "'" + |
| | | ",HBankAccount='" + HBankAccount + "'" + |
| | | ",HTaxNum='" + HTaxNum + "'" + |
| | | ",HTaxRate=" + HTaxRate.ToString() + |
| | | ",HCountry='" + HCountry + "'" + |
| | | ",HCorMan='" + HCorMan + "'" + |
| | | ",HEnglishName='" + HEnglishName + "'" + |
| | | ",HEnglishAddress='" + HEnglishAddress + "'" + |
| | | ",HCurID=" + HCurID.ToString() + |
| | | ",HSSID=" + HSSID.ToString() + |
| | | ",HAreaID=" + HAreaID.ToString() + "Where HNumber='" + HNumber + "'", ref DBUtility.ClsPub.sExeReturnInfo); |
| | | } |
| | | |
| | | i++; |
| | | } |
| | | |
| | | oCN.Commit(); |
| | | |
| | | objJsonResult.code = CodeConstant.SUCCEED; |
| | | objJsonResult.count = CountConstant.SUCCEED; |
| | | objJsonResult.Message = "导入成功!"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | LogService.Write(e); |
| | | objJsonResult.code = CodeConstant.FAIL; |
| | | objJsonResult.count = CountConstant.FAIL; |
| | | objJsonResult.Message = "Exception!" + e.ToString(); |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | #endregion |
| | | #endregion |
| | | |
| | | } |
| | | } |