/// <summary> /// 编辑库别 /// </summary> /// <param name="id">库别ID</param> /// <param name="name">库别名称</param> /// <param name="description">描述</param> /// <param name="operateid">操作人</param> /// <param name="clientid">客户端ID</param> /// <returns></returns> public bool UpdateWarehouseType(string id, string name, string description, string operateid, string clientid) { var dal = new WarehouseDAL(); return(dal.UpdateWarehouseType(id, name, description)); }
/// <summary> /// 编辑仓库 /// </summary> /// <param name="id">仓库ID</param> /// <param name="name">名称</param> /// <param name="shortname">简称</param> /// <param name="citycode">地区编码</param> /// <param name="status">状态</param> /// <param name="description">描述</param> /// <param name="operateid">操作人</param> /// <param name="clientid">客户端ID</param> /// <returns></returns> public bool UpdateWareHouse(string id, string name, string shortname, string citycode, int status, string description, string operateid, string clientid) { var dal = new WarehouseDAL(); return(dal.UpdateWareHouse(id, name, shortname, citycode, status, description)); }
/// <summary> /// 编辑货位 /// </summary> /// <param name="id">ID</param> /// <param name="name">名称</param> /// <param name="status">状态</param> /// <param name="description">描述</param> /// <param name="operateid"></param> /// <param name="clientid"></param> /// <returns></returns> public bool UpdateDepotSeat(string id, string name, int status, string description, string operateid, string clientid) { var dal = new WarehouseDAL(); return(dal.UpdateDepotSeat(id, name, status, description)); }
public void IniciarIntegracaoEstoque(SAPbobsCOM.Company oCompany) { try { Repositorio repositorio = new Repositorio(); this.log.WriteLogEstoque("Inicio do Processo de Integração de Estoque"); WarehouseDAL whsDAL = new WarehouseDAL(); SAPbobsCOM.Recordset recordset = (SAPbobsCOM.Recordset)oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset); recordset = whsDAL.RecuperarSaldoEstoqueSAP(oCompany); if (recordset != null && recordset.RecordCount > 0) { for (int i = 0; i < recordset.RecordCount; i++) { try { string _itemCode = recordset.Fields.Item("ItemCode").Value.ToString(); Int16 _onHand = System.Convert.ToInt16(recordset.Fields.Item("OnHand").Value.ToString()); string warehouseId = ConfigurationManager.AppSettings["warehouseId"]; if (_itemCode.Equals("003179-055")) { string teste = string.Empty; } Task <HttpResponseMessage> response = repositorio.BuscarItemPorSKU(_itemCode, _onHand, oCompany); if (response.Result.IsSuccessStatusCode) { this.log.WriteLogTable(oCompany, EnumTipoIntegracao.Estoque, _itemCode, _itemCode, EnumStatusIntegracao.Sucesso, "Estoque atualizado com sucesso."); this.log.WriteLogEstoque("Quantidade de estoque do Produto " + _itemCode + " para o depósito " + warehouseId + " atualizada com sucesso."); } if (Convert.ToInt16(response.Result.StatusCode) == 400) { this.log.WriteLogTable(oCompany, EnumTipoIntegracao.Estoque, _itemCode, _itemCode, EnumStatusIntegracao.Erro, response.Result.ReasonPhrase); this.log.WriteLogEstoque("Não foi possível atualizar a quantidade de estoque para o produto " + _itemCode + ". Retorno API Vtex: " + response.Result.ReasonPhrase); } } catch (Exception) { throw; } recordset.MoveNext(); } } if (recordset != null) { System.Runtime.InteropServices.Marshal.ReleaseComObject(recordset); } //Log.WriteLog("Atualização controle executação."); // Environment.SetEnvironmentVariable("controleExecucao", DateTime.Now.ToUniversalTime().ToString("s") + "Z"); } catch (Exception e) { this.log.WriteLogTable(oCompany, EnumTipoIntegracao.Estoque, "", "", EnumStatusIntegracao.Erro, e.Message); this.log.WriteLogEstoque("Exception IniciarProcessoEstoque " + e.Message); throw; } }
public void IniciarIntegracaoEstoque(SAPbobsCOM.Company oCompany) { string numItemTeste = string.Empty; try { Repositorio repositorio = new Repositorio(); this.log.WriteLogEstoque("Inicio do Processo de Integração de Estoque"); WarehouseDAL whsDAL = new WarehouseDAL(); SAPbobsCOM.Recordset recordset = (SAPbobsCOM.Recordset)oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset); recordset = whsDAL.RecuperarSaldoEstoqueSAP(oCompany); if (recordset != null && recordset.RecordCount > 0) { for (int i = 0; i < recordset.RecordCount; i++) { try { string _itemCode = recordset.Fields.Item("ItemCode").Value.ToString(); Int16 _onHand = System.Convert.ToInt16(recordset.Fields.Item("OnHand").Value.ToString()); string warehouseId = ConfigurationManager.AppSettings["warehouseId"]; numItemTeste = _itemCode; Task <HttpResponseMessage> response = repositorio.BuscarItemPorSKU(_itemCode, oCompany); if (response.Result.IsSuccessStatusCode) { Item item = new Item(); var jsonResponse = response.Result.Content.ReadAsStringAsync(); item = JsonConvert.DeserializeObject <Item>(jsonResponse.Result); //Log.WriteLog("Item " + item.ManufacturerCode + " localizado."); if (item.Status) { Task <HttpResponseMessage> responseAtualizacaoEstoque = repositorio.AtualizarQuantidadeEstoque(_itemCode, _onHand); if (responseAtualizacaoEstoque.Result.IsSuccessStatusCode) { this.log.WriteLogTable(oCompany, EnumTipoIntegracao.Estoque, _itemCode, _itemCode, EnumStatusIntegracao.Sucesso, "Estoque atualizado com sucesso."); this.log.WriteLogEstoque("Quantidade de estoque do Produto " + _itemCode + " para o depósito " + warehouseId + " atualizada com sucesso."); } else { this.log.WriteLogTable(oCompany, EnumTipoIntegracao.Estoque, _itemCode, _itemCode, EnumStatusIntegracao.Erro, response.Result.ReasonPhrase); this.log.WriteLogEstoque("Não foi possível atualizar a quantidade de estoque para o produto " + _itemCode + ". Retorno API IntegraCommerce: " + response.Result.ReasonPhrase); } } } } catch (Exception e) { throw e; } recordset.MoveNext(); } } if (recordset != null) { System.Runtime.InteropServices.Marshal.ReleaseComObject(recordset); } } catch (Exception e) { this.log.WriteLogTable(oCompany, EnumTipoIntegracao.Estoque, "", "", EnumStatusIntegracao.Erro, e.Message + numItemTeste); this.log.WriteLogEstoque("Exception IniciarProcessoEstoque " + e.Message); throw; } }
public void IniciarIntegracaoEstoque(SAPbobsCOM.Company oCompany) { try { Repositorio repositorio = new Repositorio(); this.log.WriteLogEstoque("Inicio do Processo de Integração de Estoque"); WarehouseDAL whsDAL = new WarehouseDAL(); SAPbobsCOM.Recordset recordset = (SAPbobsCOM.Recordset)oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset); recordset = whsDAL.RecuperarSaldoEstoqueSAP(oCompany); if (recordset != null && recordset.RecordCount > 0) { for (int i = 0; i < recordset.RecordCount; i++) { try { string _itemCode = recordset.Fields.Item("ItemCode").Value.ToString(); Int16 _onHand = System.Convert.ToInt16(recordset.Fields.Item("OnHand").Value.ToString()); Task <HttpResponseMessage> itemResp = repositorio.RecuperarItemPorSKUSAP(_itemCode); if (itemResp.Result.IsSuccessStatusCode) { //desseralializar item var jsonItemML = itemResp.Result.Content.ReadAsStringAsync().Result; var itemML = JsonConvert.DeserializeObject <ItemML>(jsonItemML); foreach (String itemIdML in itemML.results) { Task <HttpResponseMessage> responseAttEstoque = repositorio.AtualizarQuantidadeEstoque(itemIdML, _onHand); if (responseAttEstoque.Result.IsSuccessStatusCode) { this.log.WriteLogTable(oCompany, EnumTipoIntegracao.Estoque, _itemCode, _itemCode, EnumStatusIntegracao.Sucesso, "Estoque atualizado com sucesso."); this.log.WriteLogEstoque("Quantidade de estoque do Produto " + _itemCode + " atualizada com sucesso."); } } } } catch (Exception e) { this.log.WriteLogEstoque("Exception IniciarProcessoEstoque " + e.Message); throw; } recordset.MoveNext(); } } if (recordset != null) { System.Runtime.InteropServices.Marshal.ReleaseComObject(recordset); } //Log.WriteLog("Atualização controle executação."); // Environment.SetEnvironmentVariable("controleExecucao", DateTime.Now.ToUniversalTime().ToString("s") + "Z"); } catch (Exception e) { this.log.WriteLogTable(oCompany, EnumTipoIntegracao.Estoque, "", "", EnumStatusIntegracao.Erro, e.Message); this.log.WriteLogEstoque("Exception IniciarProcessoEstoque " + e.Message); throw; } }
protected void Page_Load(object sender, EventArgs e) { wd = new WarehouseDAL(); vd = new VersionDAL(); bd = new BranchDAL(); if (int.TryParse(Request.QueryString["wid"], out wid) == false) { //error } if (int.TryParse(Request.QueryString["vid"], out vid) == false) { //error } if (wid == 0 || vid == 0) { //error } //debug!!!!!!!!!!!!!!!!!!!!!!! //wid = 1; //vid = 1; //User u = new User(); //u.user_id = 1; //UserDAL ud = new UserDAL(); //ud.SelectByID(ref u); //Session["user"] = u; w = new Warehouse(); w.warehouse_id = wid; if (!wd.SelectedByID(ref w)) { //error } v = new Version(); v.version_id = vid; if (!vd.SelectByID(ref v)) { //error } b = new Branch(); b.branch_id = v.branch_id; if (!bd.SelectByID(ref b)) { //error } //head headName.InnerText = w.warehouse_name; headDesc.InnerText = w.warehouse_description; //current version curBran.InnerText = "当前分支:" + b.branch_name; curVer.InnerText = "当前版本:" + v.version_id.ToString(); curTime.InnerText = "修改时间:" + v.timestamp; curDesc.InnerText = "当前版本描述:" + v.description; //draw if (!DrawGraph()) { } //file fileInit(); }
public void IniciarIntegracaoEstoque(SAPbobsCOM.Company oCompany) { try { Repositorio repositorio = new Repositorio(); WarehouseDAL whsDAL = new WarehouseDAL(); SAPbobsCOM.Recordset recordset = (SAPbobsCOM.Recordset)oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset); recordset = whsDAL.RecuperarSaldoEstoqueSAP(oCompany); if (recordset != null && recordset.RecordCount > 0) { for (int i = 0; i < recordset.RecordCount; i++) { try { string _itemCode = recordset.Fields.Item("ItemCode").Value.ToString(); Int16 _onHand = System.Convert.ToInt16(recordset.Fields.Item("OnHand").Value.ToString()); Task <HttpResponseMessage> itemResp = repositorio.RecuperarItemPorSKU(_itemCode); if (itemResp.Result.IsSuccessStatusCode) { Task <HttpResponseMessage> responseAttEstoque = repositorio.AtualizarQuantidadeEstoque(_itemCode, _onHand); if (responseAttEstoque.Result.IsSuccessStatusCode) { this.log.WriteLogTable(oCompany, EnumTipoIntegracao.Estoque, _itemCode, _itemCode, EnumStatusIntegracao.Sucesso, "Estoque atualizado com sucesso."); this.log.WriteLogEstoque("Quantidade de estoque do Produto " + _itemCode + " atualizada com sucesso."); } else if (responseAttEstoque.Result.StatusCode == System.Net.HttpStatusCode.Unauthorized) { this.GetNewAccessToken(); } } else if (itemResp.Result.StatusCode == System.Net.HttpStatusCode.Unauthorized) { this.GetNewAccessToken(); } } catch (Exception) { throw; } recordset.MoveNext(); } } if (recordset != null) { System.Runtime.InteropServices.Marshal.ReleaseComObject(recordset); } } catch (Exception e) { this.log.WriteLogTable(oCompany, EnumTipoIntegracao.Estoque, "", "", EnumStatusIntegracao.Erro, e.Message); this.log.WriteLogEstoque("Exception IntegracaoService.IniciarIntegracaoEstoque " + e.Message); } }
/// <summary> /// 执行导入EXCEL数据 /// </summary> /// <param name="dataTable"></param> /// <param name="fieldNames"></param> /// <returns></returns> public bool ImportDataByExcel(DataTable dataTable, Dictionary <string, string> fieldNames, string loginUser) { List <VmiSupplierInfo> vmiSupplierExcelInfos = CommonDAL.DatatableConvertToList <VmiSupplierInfo>(dataTable).ToList(); if (vmiSupplierExcelInfos.Count == 0) { throw new Exception("MC:1x00000043");///数据格式不符合导入规范 } ///获取业务表中要变更的数据集合,准备对比 List <VmiSupplierInfo> vmiSupplierInfos = new VmiSupplierDAL().GetListForInterfaceDataSync(vmiSupplierExcelInfos.Select(d => d.SupplierNum).ToList()); List <SupplierInfo> supplierInfos = new SupplierDAL().GetListForInterfaceDataSync(vmiSupplierExcelInfos.Select(d => d.SupplierNum).ToList()); List <WarehouseInfo> warehouseInfos = new WarehouseDAL().GetListForInterfaceDataSync(vmiSupplierExcelInfos.Select(d => d.WmNo).ToList()); ///执行的SQL语句 string sql = string.Empty; List <string> fields = new List <string>(fieldNames.Keys); ///逐条处理中间表数据 foreach (var vmiSupplierExcelInfo in vmiSupplierExcelInfos) { ///当前业务数据表中此工厂的该物流路线时需要新增 VmiSupplierInfo vmiSupplierInfo = vmiSupplierInfos.FirstOrDefault(d => d.SupplierNum == vmiSupplierExcelInfo.SupplierNum && d.WmNo == vmiSupplierExcelInfo.WmNo); SupplierInfo supplierInfo = supplierInfos.FirstOrDefault(d => d.SupplierNum == vmiSupplierExcelInfo.SupplierNum); if (supplierInfo == null) { throw new Exception("MC:0x00000229");///供应商信息不存在 } WarehouseInfo warehouseInfo = warehouseInfos.FirstOrDefault(d => d.Warehouse == vmiSupplierExcelInfo.WmNo); if (warehouseInfo == null) { throw new Exception("MC:0x00000230");///仓库信息不存在 } vmiSupplierExcelInfo.SupplierName = supplierInfo.SupplierName; if (vmiSupplierInfo == null) { if (string.IsNullOrEmpty(vmiSupplierExcelInfo.SupplierNum) || string.IsNullOrEmpty(vmiSupplierExcelInfo.WmNo)) { throw new Exception("MC:0x00000228");///供应商与仓库为必填项 } ///字段 string insertFieldString = string.Empty; ///值 string insertValueString = string.Empty; for (int i = 0; i < fields.Count; i++) { string valueStr = CommonDAL.GetFieldValueForSql <VmiSupplierInfo>(vmiSupplierExcelInfo, fields[i]); if (string.IsNullOrEmpty(valueStr)) { throw new Exception("MC:1x00000043");///数据格式不符合导入规范 } insertFieldString += "[" + fieldNames[fields[i]] + "],"; insertValueString += valueStr + ","; } ///判断业务主键是否重复,以防止EXCEL中有重复数据,适用于基础数据导入 sql += "if not exists (select * from LES.TM_BAS_VMI_SUPPLIER with(nolock) " + "where [SUPPLIER_NUM] = N'" + vmiSupplierExcelInfo.SupplierNum + "' and [WM_NO] = N'" + vmiSupplierExcelInfo.WmNo + "' and [VALID_FLAG] = 1)" + " insert into [LES].[TM_BAS_VMI_SUPPLIER] (" + "[FID]," + insertFieldString + "[CREATE_USER]," + "[CREATE_DATE]," + "[VALID_FLAG]" + ") values (" + "NEWID()," ///FID + insertValueString + "N'" + loginUser + "'," ///CREATE_USER + "GETDATE()," ///CREATE_DATE + "1" ///VALID_FLAG + ");"; continue; } if (string.IsNullOrEmpty(vmiSupplierExcelInfo.SupplierNum) || string.IsNullOrEmpty(vmiSupplierExcelInfo.WmNo)) { throw new Exception("MC:0x00000228");///供应商与仓库为必填项 } ///值 string valueString = string.Empty; for (int i = 0; i < fields.Count; i++) { string valueStr = CommonDAL.GetFieldValueForSql <VmiSupplierInfo>(vmiSupplierExcelInfo, fields[i]); if (string.IsNullOrEmpty(valueStr)) { throw new Exception("MC:1x00000043");///数据格式不符合导入规范 } valueString += "[" + fieldNames[fields[i]] + "] = " + valueStr + ","; } sql += "update [LES].[TM_BAS_VMI_SUPPLIER] set " + valueString + "[MODIFY_USER] = N'" + loginUser + "'," + "[MODIFY_DATE] = GETDATE() " + "where [ID] = " + vmiSupplierInfo.Id + ";"; } /// if (string.IsNullOrEmpty(sql)) { return(false); } return(CommonDAL.ExecuteNonQueryBySql(sql)); }
protected void createButton_Click(object sender, EventArgs e) { User u = (User)Session["user"]; if (u == null) { Response.Write("<script>alert('invalid user 1.');window.opener=null;window.close();</script>"); return; } if (v == null) { Response.Write("<script>alert('invalid vid in create.');window.opener=null;window.close();</script>"); return; } if (u.user_id != v.user_id) { Response.Write("<script>alert('invalid user.');window.opener=null;window.close();</script>"); return; } if (name.Value.Length == 0 || desc.Value.Length == 0) { //error Response.Write("<script>alert('invalid name or desc.');</script>"); return; } //new version Version v2 = new Version(); v2.version_name = name.Value; v2.description = desc.Value; v2.prev_id = v.version_id; //! v2.next_id = v.next_id; //! v2.warehouse_id = v.warehouse_id; v2.user_id = v.user_id; v2.branch_id = v.branch_id; if (!vd.Insert(ref v2)) { Response.Write("<script>alert('insert error 1.');</script>"); return; } Version v3 = new Version(); v3.branch_id = v.branch_id; v3.description = v.description; v3.next_id = v2.version_id; //warning v3.prev_id = v.prev_id; //warning v3.timestamp = v.timestamp; v3.user_id = v.user_id; v3.version_id = v.version_id; v3.version_name = v.version_name; v3.warehouse_id = v.warehouse_id; if (!vd.Update(ref v3)) { Response.Write("<script>alert('error 3.');</script>"); vd.Delete(ref v2); vd.Update(ref v); return; } //create files if (!FileSystem.CopyFolder(Server.MapPath("~/") + @"data\" + v.warehouse_id.ToString() + @"\" + v.version_id.ToString(), Server.MapPath("~/") + @"data\" + v.warehouse_id.ToString() + @"\" + v2.version_id.ToString())) { vd.Delete(ref v2); vd.Update(ref v); Response.Write("<script>alert('file error.');</script>"); return; } //warnning ; bug here Branch b = new Branch(); b.branch_id = v.branch_id; bd = new BranchDAL(); bd.SelectByID(ref b); if (b.branch_name == "master") { Warehouse w = new Warehouse(); w.warehouse_id = v.warehouse_id; wd = new WarehouseDAL(); wd.SelectedByID(ref w); if (w.master_version_id == v.version_id) { w.master_version_id = v2.version_id; wd.Update(ref w); } } Response.Write("<script>alert('create success.');window.location.href='warehouse_page.aspx?wid=" + v.warehouse_id + "&vid=" + v2.version_id + "';</script>"); }
/// <summary> /// 执行导入EXCEL数据 /// </summary> /// <param name="dataTable"></param> /// <param name="fieldNames"></param> /// <returns></returns> public bool ImportDataByExcel(DataTable dataTable, Dictionary <string, string> fieldNames, string loginUser) { List <WarehouseLocationInfo> warehouseLocationExcelInfos = CommonDAL.DatatableConvertToList <WarehouseLocationInfo>(dataTable).ToList(); if (warehouseLocationExcelInfos.Count == 0) { throw new Exception("MC:1x00000043");///数据格式不符合导入规范 } ///获取业务表中要变更的数据集合,准备对比 List <WarehouseLocationInfo> warehouseLocationInfos = new WarehouseLocationDAL().GetList("" + "[DLOC] in ('" + string.Join("','", warehouseLocationExcelInfos.Select(d => d.Dloc).ToArray()) + "')", string.Empty); ///存储区 List <ZonesInfo> zonesInfos = new ZonesDAL().GetList("" + "[ZONE_NO] in ('" + string.Join("','", warehouseLocationExcelInfos.Select(d => d.ZoneNo).ToArray()) + "')", string.Empty); ///仓库 List <WarehouseInfo> warehouseInfos = new WarehouseDAL().GetList("" + "[WAREHOUSE] in ('" + string.Join("','", warehouseLocationExcelInfos.Select(d => d.WmNo).ToArray()) + "')", string.Empty); ///允许存储区代码在不同的仓库中重复使用 string allow_zoneno_repeat_at_different_warehouse = new ConfigDAL().GetValueByCode("ALLOW_ZONENO_REPEAT_AT_DIFFERENT_WAREHOUSE"); ///允许库位代码在不同的存储区中重复使用 string allowDlocRepeatAtDifferentZone = new ConfigDAL().GetValueByCode("ALLOW_DLOC_REPEAT_AT_DIFFERENT_ZONE"); ///执行的SQL语句 StringBuilder @string = new StringBuilder(); List <string> fields = new List <string>(fieldNames.Keys); ///逐条处理中间表数据 foreach (var warehouseLocationExcelInfo in warehouseLocationExcelInfos) { WarehouseInfo warehouseInfo = warehouseInfos.FirstOrDefault(d => d.Warehouse == warehouseLocationExcelInfo.WmNo); if (warehouseInfo == null) { throw new Exception("MC:0x00000230");///仓库信息不存在 } ZonesInfo zonesInfo = zonesInfos.FirstOrDefault(d => d.ZoneNo == warehouseLocationExcelInfo.ZoneNo && d.WmNo == warehouseLocationExcelInfo.WmNo); if (zonesInfo == null) { throw new Exception("MC:0x00000500");///存储区不存在 } ///数据校验 ValidInfo(warehouseLocationExcelInfo, allow_zoneno_repeat_at_different_warehouse, allowDlocRepeatAtDifferentZone); ///当前业务数据表中此工厂的该物流路线时需要新增 WarehouseLocationInfo warehouseLocationInfo = warehouseLocationInfos.FirstOrDefault(d => d.Dloc == warehouseLocationExcelInfo.Dloc && d.ZoneNo == warehouseLocationExcelInfo.ZoneNo && d.WmNo == warehouseLocationExcelInfo.WmNo); if (warehouseLocationInfo == null) { ///字段 string insertFieldString = string.Empty; ///值 string insertValueString = string.Empty; for (int i = 0; i < fields.Count; i++) { string valueStr = CommonDAL.GetFieldValueForSql <WarehouseLocationInfo>(warehouseLocationExcelInfo, fields[i]); if (string.IsNullOrEmpty(valueStr)) { throw new Exception("MC:1x00000043");///数据格式不符合导入规范 } insertFieldString += "[" + fieldNames[fields[i]] + "],"; insertValueString += valueStr + ","; } /// warehouseLocationExcelInfo.Fid = Guid.NewGuid(); ///判断业务主键是否重复,以防止EXCEL中有重复数据,适用于基础数据导入 @string.AppendLine("if not exists (select * from [LES].[TM_BAS_WAREHOUSE_LOCATION] with(nolock) where [DLOC] = N'" + warehouseLocationExcelInfo.Dloc + "' and [VALID_FLAG] = 1)" + " insert into [LES].[TM_BAS_WAREHOUSE_LOCATION] (" + "[FID]," + insertFieldString + "[CREATE_USER]," + "[CREATE_DATE]," + "[VALID_FLAG]" + ") values (" + "N'" + warehouseLocationExcelInfo.Fid.GetValueOrDefault() + "'," ///FID + insertValueString + "N'" + loginUser + "'," ///CREATE_USER + "GETDATE()," ///CREATE_DATE + "1" ///VALID_FLAG + ");"); warehouseLocationInfos.Add(warehouseLocationExcelInfo); continue; } ///值 string valueString = string.Empty; for (int i = 0; i < fields.Count; i++) { string valueStr = CommonDAL.GetFieldValueForSql <WarehouseLocationInfo>(warehouseLocationExcelInfo, fields[i]); if (string.IsNullOrEmpty(valueStr)) { throw new Exception("MC:1x00000043");///数据格式不符合导入规范 } valueString += "[" + fieldNames[fields[i]] + "] = " + valueStr + ","; } @string.AppendLine("update [LES].[TM_BAS_WAREHOUSE_LOCATION] set " + valueString + "[MODIFY_USER] = N'" + loginUser + "'," + "[MODIFY_DATE] = GETDATE() " + "where [FID] = N'" + warehouseLocationInfo.Fid.GetValueOrDefault() + "';"); } ///执行 using (var trans = new TransactionScope()) { if (@string.Length > 0) { CommonDAL.ExecuteNonQueryBySql(@string.ToString()); } trans.Complete(); } return(true); }
protected void createButton_Click(object sender, EventArgs e) { if (Session["user"] == null) { Response.Write("<script>alert('please login.');window.location.href='login.aspx';</script>"); return; } if (name.Value.Length == 0 || desc.Value.Length == 0) { Response.Write("<script>alert('emoty data');</script>"); return; } //create warehouse User u = Session["user"] as User; Warehouse w = new Warehouse(); WarehouseDAL wd = new WarehouseDAL(); w.user_id = u.user_id; w.warehouse_name = name.Value; w.warehouse_description = desc.Value; if (wd.Insert(ref w)) { } else { Response.Write("<script>alert('error: warehouse insert');</script>"); return; } //create first version Version v = new Version(); VersionDAL vd = new VersionDAL(); v.user_id = u.user_id; v.warehouse_id = w.warehouse_id; v.version_name = "master"; v.description = "master"; if (vd.Insert(ref v)) { w.master_version_id = v.version_id; } else { //delete warehouse wd.Delete(ref w); Response.Write("<script>alert('error: version insert');</script>"); return; } if (wd.Update(ref w)) { } else { //delete warehouse and version wd.Delete(ref w); vd.Delete(ref v); Response.Write("<script>alert('error: warehouse update');</script>"); return; } //insert branch Branch b = new Branch(); BranchDAL bd = new BranchDAL(); b.warehouse_id = w.warehouse_id; b.user_id = u.user_id; b.start_id = v.version_id; b.end_id = 0; b.branch_name = "master"; b.description = "master"; if (bd.Insert(ref b)) { } else { Response.Write("<script>alert('error: branch insert');</script>"); wd.Delete(ref w); vd.Delete(ref v); return; } v.branch_id = b.branch_id; if (!vd.Update(ref v)) { Response.Write("<script>alert('error: version update');</script>"); wd.Delete(ref w); vd.Delete(ref v); bd.Delete(b.branch_id); return; } //crete files if (FileSystem.CreateFolder(Server.MapPath("~/") + @"data\" + w.warehouse_id.ToString() + @"\" + v.version_id.ToString()) == false) { Response.Write("<script>alert('error: file error');</script>"); wd.Delete(ref w); vd.Delete(ref v); bd.Delete(b.branch_id); return; } //create success Response.Write("<script>alert('create success.');window.location.href='user_page.aspx?uid=" + u.user_id.ToString() + "';</script>"); }