public ActionResult DoorAddReadingHead(int? id, string ids) { JsonObjectResult jsonObjectResult = new JsonObjectResult(); try { if (id.HasValue && !string.IsNullOrEmpty(ids)) { string[] arrId = ids.Split(','); string whereId = ""; foreach (string sid in arrId) { if (sid.Trim() != "") { if (whereId.Trim() != "") whereId += ","; whereId += sid.Trim(); } } if (whereId != "") { List<AscmReadingHead> list_Update = new List<AscmReadingHead>(); string sql = "from AscmReadingHead where id in (" + whereId + ")"; List<AscmReadingHead> list = AscmReadingHeadService.GetInstance().GetList(sql); foreach (AscmReadingHead ascmReadingHead in list) { if (ascmReadingHead.bindId != id.Value.ToString()) { ascmReadingHead.bindId = id.Value.ToString(); list_Update.Add(ascmReadingHead); } } if (list_Update.Count > 0) { AscmReadingHeadService.GetInstance().Update(list_Update); } } jsonObjectResult.result = true; jsonObjectResult.message = ""; } } catch (Exception ex) { jsonObjectResult.message = ex.Message; } return Json(jsonObjectResult, JsonRequestBehavior.AllowGet); }
public ActionResult DoorDelete(int? id) { JsonObjectResult jsonObjectResult = new JsonObjectResult(); try { if (id.HasValue) { using (ITransaction tx = YnDaoHelper.GetInstance().nHibernateHelper.GetCurrentSession().BeginTransaction()) { try { AscmDoorService.GetInstance().Delete(id.Value); tx.Commit();//正确执行提交 jsonObjectResult.result = true; jsonObjectResult.message = ""; } catch (Exception ex) { tx.Rollback();//回滚 YnBaseClass2.Helper.LogHelper.GetLog().Error("删除失败(Delete AscmDoor)", ex); throw ex; } } } else { jsonObjectResult.message = "传入参数[id=null]错误!"; } } catch (Exception ex) { jsonObjectResult.message = ex.Message; } return Json(jsonObjectResult, JsonRequestBehavior.AllowGet); }
public ContentResult MaterialCategorySave(AscmMaterialCategory ascmMaterialCategory_Model, int? id) { JsonObjectResult jsonObjectResult = new JsonObjectResult(); try { string userName = string.Empty; if (User.Identity.IsAuthenticated) { userName = User.Identity.Name; } AscmMaterialCategory ascmMaterialCategory = null; if (id.HasValue) { ascmMaterialCategory = AscmMaterialCategoryService.GetInstance().Get(id.Value); ascmMaterialCategory.modifyUser = userName; ascmMaterialCategory.modifyTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm"); } else { ascmMaterialCategory = new AscmMaterialCategory(); int maxId = YnDaoHelper.GetInstance().nHibernateHelper.GetMaxId("select max(id) from AscmMaterialCategory"); ascmMaterialCategory.id = ++maxId; ascmMaterialCategory.createUser = userName; ascmMaterialCategory.createUser = DateTime.Now.ToString("yyyy-MM-dd HH:mm"); ascmMaterialCategory.modifyUser = userName; ascmMaterialCategory.modifyTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm"); } if (ascmMaterialCategory == null) throw new Exception("保存物料大类信息失败!"); ascmMaterialCategory.description = ascmMaterialCategory_Model.description; ascmMaterialCategory.tip = ascmMaterialCategory_Model.tip; if (id.HasValue) { object object1 = YnDaoHelper.GetInstance().nHibernateHelper.GetObject("select count(*) from AscmMaterialCategory id <>" + id.Value + " "); if (object1 == null) throw new Exception("查询异常!"); int iCount = 0; if (int.TryParse(object1.ToString(), out iCount) && iCount > 0) throw new Exception("已存在此物料大类信息【" + ascmMaterialCategory_Model.categoryCode + "】"); AscmMaterialCategoryService.GetInstance().Update(ascmMaterialCategory); } else { AscmMaterialCategoryService.GetInstance().Save(ascmMaterialCategory); } jsonObjectResult.result = true; jsonObjectResult.message = ""; jsonObjectResult.id = ascmMaterialCategory.id.ToString(); jsonObjectResult.entity = ascmMaterialCategory; } catch (Exception ex) { jsonObjectResult.result = false; jsonObjectResult.message = ex.Message; } string sReturn = JsonConvert.SerializeObject(jsonObjectResult); return Content(sReturn); }
public ContentResult SupplierSave(AscmSupplier ascmSupplier_Model, int? id) { JsonObjectResult jsonObjectResult = new JsonObjectResult(); try { AscmSupplier ascmSupplier = null; if (id.HasValue) { ascmSupplier = AscmSupplierService.GetInstance().Get(id.Value); } else { ascmSupplier = new AscmSupplier(); throw new Exception("不允许增加供应商!"); } if (ascmSupplier == null) throw new Exception("保存供应商失败!"); if (ascmSupplier_Model.name == null || ascmSupplier_Model.name.Trim() == "") throw new Exception("供应商名称不能为空!"); ascmSupplier.warnHours = ascmSupplier_Model.warnHours; //ascmSupplier.name = ascmSupplier_Model.name; //ascmSupplier.enabled = ascmSupplier_Model.enabled; //ascmSupplier.description = ascmSupplier_Model.description; ascmSupplier.passDuration = ascmSupplier_Model.passDuration; if (id.HasValue) { object object1 = YnDaoHelper.GetInstance().nHibernateHelper.GetObject("select count(*) from AscmSupplier where name='" + ascmSupplier_Model.name.Trim() + "' and id<>" + id.Value + ""); if (object1 == null) throw new Exception("查询异常!"); int iCount = 0; if (int.TryParse(object1.ToString(), out iCount) && iCount > 0) throw new Exception("已经存在此供应商【" + ascmSupplier_Model.name.Trim() + "】!"); AscmSupplierService.GetInstance().Update(ascmSupplier); } jsonObjectResult.result = true; jsonObjectResult.message = ""; jsonObjectResult.id = ascmSupplier.id.ToString(); jsonObjectResult.entity = ascmSupplier; } catch (Exception ex) { jsonObjectResult.message = ex.Message; } string sReturn = JsonConvert.SerializeObject(jsonObjectResult); return Content(sReturn); }
public ContentResult EmployeeSave(AscmEmployee ascmEmployee_Model, int? id) { JsonObjectResult jsonObjectResult = new JsonObjectResult(); try { AscmEmployee ascmEmployee = null; if (id.HasValue) { ascmEmployee = AscmEmployeeService.GetInstance().Get(id.Value); } else { ascmEmployee = new AscmEmployee(); } if (ascmEmployee == null) throw new Exception("保存员工基本信息失败!"); if (ascmEmployee_Model.name == null || ascmEmployee_Model.name.Trim() == "") throw new Exception("员工名称不能为空!"); ascmEmployee.docNumber = ascmEmployee_Model.docNumber.Trim(); ascmEmployee.name = ascmEmployee_Model.name.Trim(); ascmEmployee.sex = ascmEmployee_Model.sex.Trim(); ascmEmployee.idNumber = ascmEmployee_Model.idNumber.Trim(); ascmEmployee.email = ascmEmployee_Model.email; ascmEmployee.officeTel = ascmEmployee_Model.officeTel; ascmEmployee.mobileTel = ascmEmployee_Model.mobileTel; ascmEmployee.memo = ascmEmployee_Model.memo; ascmEmployee.departmentId = ascmEmployee_Model.departmentId; if (!id.HasValue) { object object1 = YnDaoHelper.GetInstance().nHibernateHelper.GetObject("select count(*) from AscmEmployee where docNumber='" + ascmEmployee_Model.docNumber.Trim() + "'"); if (object1 == null) throw new Exception("查询异常!"); int iCount = 0; if (int.TryParse(object1.ToString(), out iCount) && iCount > 0) throw new Exception("已经存在此员工编号【" + ascmEmployee_Model.docNumber.Trim() + "】!"); object1 = YnDaoHelper.GetInstance().nHibernateHelper.GetObject("select count(*) from AscmEmployee where name='" + ascmEmployee_Model.name.Trim() + "'"); if (object1 == null) throw new Exception("查询异常!"); //int iCount = 0; if (int.TryParse(object1.ToString(), out iCount) && iCount > 0) throw new Exception("已经存在此员工姓名【" + ascmEmployee_Model.name.Trim() + "】!"); AscmEmployeeService.GetInstance().Save(ascmEmployee); } else { object object1 = YnDaoHelper.GetInstance().nHibernateHelper.GetObject("select count(*) from AscmEmployee where docNumber='" + ascmEmployee_Model.docNumber.Trim() + "' and id<>" + id.Value + ""); if (object1 == null) throw new Exception("查询异常!"); int iCount = 0; if (int.TryParse(object1.ToString(), out iCount) && iCount > 0) throw new Exception("已经存在此员工编号【" + ascmEmployee_Model.docNumber.Trim() + "】!"); object1 = YnDaoHelper.GetInstance().nHibernateHelper.GetObject("select count(*) from AscmEmployee where name='" + ascmEmployee_Model.name.Trim() + "' and id<>" + id.Value + ""); if (object1 == null) throw new Exception("查询异常!"); //int iCount = 0; if (int.TryParse(object1.ToString(), out iCount) && iCount > 0) throw new Exception("已经存在此员工姓名【" + ascmEmployee_Model.name.Trim() + "】!"); AscmEmployeeService.GetInstance().Update(ascmEmployee); } jsonObjectResult.result = true; jsonObjectResult.message = ""; jsonObjectResult.id = ascmEmployee.id.ToString(); jsonObjectResult.entity = ascmEmployee; } catch (Exception ex) { jsonObjectResult.message = ex.Message; } string sReturn = JsonConvert.SerializeObject(jsonObjectResult); return Content(sReturn); }
public ActionResult EmployeeDelete(int? id) { JsonObjectResult jsonObjectResult = new JsonObjectResult(); try { if (id.HasValue) { using (ITransaction tx = YnDaoHelper.GetInstance().nHibernateHelper.GetCurrentSession().BeginTransaction()) { try { /* //删除与用户的关联 string sql = "from YnUserRoleLink where ids.roleId=" + id; IList<YnUserRoleLink> ilistUserRoleLink = YnDaoHelper.GetInstance().nHibernateHelper.Find<YnUserRoleLink>(sql); if (ilistUserRoleLink != null && ilistUserRoleLink.Count > 0) { List<YnUserRoleLink> list = YnBaseClass2.Helper.ConvertHelper.ConvertIListToList<YnUserRoleLink>(ilistUserRoleLink); YnDaoHelper.GetInstance().nHibernateHelper.DeleteList(list); } //删除与模块的关联 sql = "from YnWebModuleRoleLink where ynRole.id=" + id; IList<YnWebModuleRoleLink> ilistModuleRoleLink = YnDaoHelper.GetInstance().nHibernateHelper.Find<YnWebModuleRoleLink>(sql); if (ilistModuleRoleLink != null && ilistModuleRoleLink.Count > 0) { List<YnWebModuleRoleLink> list = YnBaseClass2.Helper.ConvertHelper.ConvertIListToList<YnWebModuleRoleLink>(ilistModuleRoleLink); YnDaoHelper.GetInstance().nHibernateHelper.DeleteList(list); } //删除角色 YnRole ynRole = YnDaoHelper.GetInstance().nHibernateHelper.Get<YnRole>(id.Value); YnDaoHelper.GetInstance().nHibernateHelper.Delete<YnRole>(ynRole); */ AscmEmployeeService.GetInstance().Delete(id.Value); tx.Commit();//正确执行提交 jsonObjectResult.result = true; jsonObjectResult.message = ""; } catch (Exception ex) { tx.Rollback();//回滚 YnBaseClass2.Helper.LogHelper.GetLog().Error("删除失败(Delete AscmEmployee)", ex); throw ex; } } } else { jsonObjectResult.message = "传入参数[id=null]错误!"; } } catch (Exception ex) { jsonObjectResult.message = ex.Message; } return Json(jsonObjectResult, JsonRequestBehavior.AllowGet); }
public ContentResult DoorSave(AscmDoor ascmDoor_Model, int? id) { JsonObjectResult jsonObjectResult = new JsonObjectResult(); try { AscmDoor ascmDoor = null; if (id.HasValue) { ascmDoor = AscmDoorService.GetInstance().Get(id.Value); } else { ascmDoor = new AscmDoor(); ascmDoor.enabled = true; } if (ascmDoor == null) throw new Exception("保存大门信息失败!"); if (string.IsNullOrEmpty(ascmDoor_Model.name)) throw new Exception("必须输入名称!"); //if (ascmReadingHead_Model.plateNumber == null || ascmReadingHead_Model.plateNumber.Trim() == "") // throw new Exception("员工车辆车牌号不能为空!"); ascmDoor.name = ascmDoor_Model.name.Trim(); ascmDoor.direction = ascmDoor_Model.direction; ascmDoor.vehicleType = ascmDoor_Model.vehicleType; ascmDoor.description = ascmDoor_Model.description; if (!id.HasValue) { object object1 = YnDaoHelper.GetInstance().nHibernateHelper.GetObject("select count(*) from AscmDoor where name='" + ascmDoor_Model.name.Trim() + "'"); if (object1 == null) throw new Exception("查询异常!"); int iCount = 0; if (int.TryParse(object1.ToString(), out iCount) && iCount > 0) throw new Exception("已经存在大门【" + ascmDoor_Model.name.Trim() + "】!"); int maxId = YnDaoHelper.GetInstance().nHibernateHelper.GetMaxId("select max(id) from AscmDoor"); ascmDoor.id = maxId + 1; } else { object object1 = YnDaoHelper.GetInstance().nHibernateHelper.GetObject("select count(*) from AscmDoor where name='" + ascmDoor_Model.name.Trim() + "' and id<>" + id.Value + ""); if (object1 == null) throw new Exception("查询异常!"); int iCount = 0; if (int.TryParse(object1.ToString(), out iCount) && iCount > 0) throw new Exception("已经存在大门【" + ascmDoor_Model.name.Trim() + "】!"); //AscmEmployeeCarService.GetInstance().Update(ascmEmployeeCar); } using (ITransaction tx = YnDaoHelper.GetInstance().nHibernateHelper.GetCurrentSession().BeginTransaction()) { try { if (!id.HasValue) { YnDaoHelper.GetInstance().nHibernateHelper.Save(ascmDoor); } else { YnDaoHelper.GetInstance().nHibernateHelper.Update(ascmDoor); } tx.Commit();//正确执行提交 } catch (Exception ex) { tx.Rollback();//回滚 throw ex; } } jsonObjectResult.result = true; jsonObjectResult.message = ""; jsonObjectResult.id = ascmDoor.id.ToString(); jsonObjectResult.entity = ascmDoor; } catch (Exception ex) { jsonObjectResult.message = ex.Message; } string sReturn = JsonConvert.SerializeObject(jsonObjectResult); return Content(sReturn); }
public ActionResult SupplierMaterialDelete(string ids, int? supplierId) { JsonObjectResult jsonObjectResult = new JsonObjectResult(); try { if (!supplierId.HasValue) throw new Exception("供应商ID传值错误!"); if (!string.IsNullOrEmpty(ids)) { string whereOther = string.Empty; whereOther = " supplierId=" + supplierId.Value + " and materialId in (" + ids + ")"; List<AscmSupplierMaterialLink> list = AscmSupplierMaterialLinkService.GetInstance().GetList("", "", "", whereOther); if (list != null && list.Count() > 0) { AscmSupplierMaterialLinkService.GetInstance().Delete(list); jsonObjectResult.result = true; jsonObjectResult.message = ""; } } else { jsonObjectResult.message = "传入参数[id=null]错误!"; } } catch (Exception ex) { jsonObjectResult.message = ex.Message; } return Json(jsonObjectResult, JsonRequestBehavior.AllowGet); }
public ContentResult SetLogisticsYnUserClass(string id, AscmUserInfo ascmUserInfo_Model) { JsonObjectResult jsonObjectResult = new JsonObjectResult(); try { string userName = string.Empty; if (User.Identity.IsAuthenticated) { userName = User.Identity.Name; } AscmUserInfo ascmUserInfo = null; if (!string.IsNullOrEmpty(id)) { ascmUserInfo = AscmUserInfoService.GetInstance().Get(id); if (!string.IsNullOrEmpty(ascmUserInfo_Model.logisticsClass)) ascmUserInfo.logisticsClass = ascmUserInfo_Model.logisticsClass; AscmUserInfoService.GetInstance().Update(ascmUserInfo); } jsonObjectResult.result = true; jsonObjectResult.message = ""; jsonObjectResult.id = ascmUserInfo.userId; jsonObjectResult.entity = ascmUserInfo; } catch (Exception ex) { jsonObjectResult.result = false; jsonObjectResult.message = ex.Message; } string sReturn = JsonConvert.SerializeObject(jsonObjectResult); return Content(sReturn); }
public ContentResult AllocateLogisticsTaskEditSave(AscmGetMaterialTask ascmGetMaterialTask_Model, int? id) { JsonObjectResult jsonObjectResult = new JsonObjectResult(); string userName = string.Empty; if (User.Identity.IsAuthenticated) { userName = User.Identity.Name; } try { if (id.HasValue) { AscmGetMaterialTask ascmGetMaterialTask = AscmGetMaterialTaskService.GetInstance().Get(ascmGetMaterialTask_Model.id); if (ascmGetMaterialTask.taskId.Substring(0, 1) == AscmCommonHelperService.GetInstance().GetConfigTaskWords(0)) { string ids = string.Empty; if (!string.IsNullOrEmpty(ascmGetMaterialTask.workerId)) ids += "'" + ascmGetMaterialTask.workerId + "'"; if (!string.IsNullOrEmpty(ids) && !string.IsNullOrEmpty(ascmGetMaterialTask_Model.WorkerName)) ids += ","; if (!string.IsNullOrEmpty(ascmGetMaterialTask_Model.WorkerName)) ids += "'" + ascmGetMaterialTask_Model.WorkerName + "'"; string whereOther = "", whereQueryWord = ""; whereQueryWord = "workerName in (" + ids + ")"; whereOther = YnBaseClass2.Helper.StringHelper.SqlWhereAndAdd(whereOther, whereQueryWord); List<AscmAllocateRule> list = AscmAllocateRuleService.GetInstance().GetList(null, "", "", "", whereOther); if (list != null && list.Count > 0) { foreach (AscmAllocateRule ascmAllocateRule in list) { if (ascmAllocateRule.workerName == ascmGetMaterialTask.workerId) { ascmAllocateRule.taskCount++; } else if (ascmAllocateRule.workerName == ascmGetMaterialTask_Model.WorkerName) { ascmAllocateRule.taskCount--; } ascmAllocateRule.modifyUser = userName; ascmAllocateRule.modifyTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm"); } } AscmAllocateRuleService.GetInstance().Update(list); } if (!string.IsNullOrEmpty(ascmGetMaterialTask_Model.WorkerName)) { ascmGetMaterialTask.workerId = ascmGetMaterialTask_Model.WorkerName; ascmGetMaterialTask.status = "NOTEXECUTE"; AscmGetMaterialTaskService.GetInstance().Update(ascmGetMaterialTask); } } jsonObjectResult.result = true; jsonObjectResult.message = ""; } catch (Exception ex) { jsonObjectResult.result = false; jsonObjectResult.message = ex.Message; } string sReturn = JsonConvert.SerializeObject(jsonObjectResult); return Content(sReturn); }
public ContentResult MaterialSubCategorySave(AscmMaterialSubCategory ascmMaterialSubCategory_Model, int? id) { JsonObjectResult jsonObjectResult = new JsonObjectResult(); try { string userName = string.Empty; if (User.Identity.IsAuthenticated) { userName = User.Identity.Name; } AscmMaterialSubCategory ascmMaterialSubCategory = null; if (id.HasValue) { ascmMaterialSubCategory = AscmMaterialSubCategoryService.GetInstance().Get(id.Value); ascmMaterialSubCategory.modifyUser = userName; ascmMaterialSubCategory.modifyTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm"); } else { ascmMaterialSubCategory = new AscmMaterialSubCategory(); int maxId = YnDaoHelper.GetInstance().nHibernateHelper.GetMaxId("select max(id) from AscmMaterialSubCategory"); ascmMaterialSubCategory.id = ++maxId; ascmMaterialSubCategory.createUser = userName; ascmMaterialSubCategory.createTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm"); ascmMaterialSubCategory.modifyUser = userName; ascmMaterialSubCategory.modifyTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm"); } if (ascmMaterialSubCategory == null) throw new Exception("保存物料子类信息失败 !"); if (ascmMaterialSubCategory_Model.subCategoryCode == null || ascmMaterialSubCategory_Model.subCategoryCode == "") throw new Exception("物料子类不能为空!"); ascmMaterialSubCategory.zMtlCategoryStatus = ascmMaterialSubCategory_Model.zMtlCategoryStatus; ascmMaterialSubCategory.dMtlCategoryStatus = ascmMaterialSubCategory_Model.dMtlCategoryStatus; ascmMaterialSubCategory.wMtlCategoryStatus = ascmMaterialSubCategory_Model.wMtlCategoryStatus; ascmMaterialSubCategory.description = ascmMaterialSubCategory_Model.description; ascmMaterialSubCategory.tip = ascmMaterialSubCategory_Model.tip; if (id.HasValue) AscmMaterialSubCategoryService.GetInstance().Update(ascmMaterialSubCategory); else AscmMaterialSubCategoryService.GetInstance().Save(ascmMaterialSubCategory); jsonObjectResult.result = true; jsonObjectResult.message = ""; //jsonObjectResult.id = ascmMaterialSubCategory.id.ToString(); //jsonObjectResult.entity = ascmMaterialSubCategory; } catch (Exception ex) { jsonObjectResult.result = false; jsonObjectResult.message = ex.Message; } string sReturn = JsonConvert.SerializeObject(jsonObjectResult); return Content(sReturn); }
public ContentResult MaterialStockFormatSave(AscmMaterialItem ascmMaterialItem_Model, int? id) { JsonObjectResult jsonObjectReuslt = new JsonObjectResult(); string userName = string.Empty; if (User.Identity.IsAuthenticated) { userName = User.Identity.Name; } try { AscmMaterialItem ascmMaterialItem = null; if (!id.HasValue) throw new Exception("未选择或获取物料信息!"); ascmMaterialItem = AscmMaterialItemService.GetInstance().Get(id.Value); ascmMaterialItem.modifyTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm"); ascmMaterialItem.modifyUser = userName; ascmMaterialItem.zMtlCategoryStatus = ascmMaterialItem_Model.zMtlCategoryStatus; ascmMaterialItem.dMtlCategoryStatus = ascmMaterialItem_Model.dMtlCategoryStatus; ascmMaterialItem.wMtlCategoryStatus = ascmMaterialItem_Model.wMtlCategoryStatus; AscmMaterialItemService.GetInstance().Update(ascmMaterialItem); jsonObjectReuslt.result = true; jsonObjectReuslt.message = ""; jsonObjectReuslt.id = ascmMaterialItem.id.ToString(); jsonObjectReuslt.entity = ascmMaterialItem; } catch (Exception ex) { jsonObjectReuslt.result = false; jsonObjectReuslt.message = ex.Message; } string sReturn = JsonConvert.SerializeObject(jsonObjectReuslt); return Content(sReturn); }
public ContentResult MaterialStockFormatRepair() { string userName = string.Empty; if (User.Identity.IsAuthenticated) { userName = User.Identity.Name; } JsonObjectResult jsonObjectResult = new JsonObjectResult(); List<AscmMaterialItem> list = null; try { string sql = string.Empty; object obj = YnDaoHelper.GetInstance().nHibernateHelper.GetCount("select count(*) from AscmMaterialItem where isFlag = 0"); int nI = 0; int times = 0; if (int.TryParse(obj.ToString(), out nI) && nI > 0) { decimal temp = Convert.ToDecimal(nI) / 10000; times = Convert.ToInt16(Math.Ceiling(temp)); } if (times > 0) { for (int i = 0; i < times; i++) { #region 维护逻辑 sql = "from AscmMaterialItem where isFlag = 0 and rownum <= 10000 order by id"; IList<AscmMaterialItem> ilist = YnDaoHelper.GetInstance().nHibernateHelper.Find<AscmMaterialItem>(sql); if (ilist != null && ilist.Count > 0) { foreach (AscmMaterialItem ascmMaterialItem in ilist) { //添加物料大类 string categoryStr = ascmMaterialItem.docNumber.Substring(0, 4); object objcategory = YnDaoHelper.GetInstance().nHibernateHelper.GetCount("select count(*) from AscmMaterialCategory where categoryCode = '" + categoryStr + "'"); int categoryNI = 0; if (int.TryParse(objcategory.ToString(), out categoryNI) && categoryNI == 0) { AscmMaterialCategory ascmMaterialCategory = new AscmMaterialCategory(); int maxId = YnDaoHelper.GetInstance().nHibernateHelper.GetMaxId("select max(id) from AscmMaterialCategory"); ascmMaterialCategory.id = ++maxId; ascmMaterialCategory.createUser = userName; ascmMaterialCategory.createTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm"); ascmMaterialCategory.modifyUser = userName; ascmMaterialCategory.modifyTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm"); ascmMaterialCategory.categoryCode = categoryStr; AscmMaterialCategoryService.GetInstance().Save(ascmMaterialCategory); } //添加物料小类 string subcategoryStr = ascmMaterialItem.docNumber.Substring(4, 3); AscmMaterialCategory category = AscmMaterialCategoryService.GetInstance().GetId(categoryStr); string combinationCode = categoryStr + "." + subcategoryStr; object objsubcategory = YnDaoHelper.GetInstance().nHibernateHelper.GetCount("select count(*) from AscmMaterialSubCategory where subCategoryCode = '" + subcategoryStr + "' and categoryId = " + category.id); int subcategoryNI = 0; if (int.TryParse(objsubcategory.ToString(), out subcategoryNI) && subcategoryNI == 0) { AscmMaterialSubCategory ascmMaterialSubCategory = new AscmMaterialSubCategory(); int maxId = YnDaoHelper.GetInstance().nHibernateHelper.GetMaxId("select max(id) from AscmMaterialSubCategory"); ascmMaterialSubCategory.id = ++maxId; ascmMaterialSubCategory.createUser = userName; ascmMaterialSubCategory.createTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm"); ascmMaterialSubCategory.modifyUser = userName; ascmMaterialSubCategory.modifyTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm"); ascmMaterialSubCategory.subCategoryCode = subcategoryStr; ascmMaterialSubCategory.categoryId = category.id; ascmMaterialSubCategory.combinationCode = categoryStr + "." + subcategoryStr; AscmMaterialSubCategoryService.GetInstance().Save(ascmMaterialSubCategory); } else if (int.TryParse(objsubcategory.ToString(), out subcategoryNI) && subcategoryNI > 0) { sql = "from AscmMaterialSubCategory where combinationCode = '" + combinationCode + "'"; IList<AscmMaterialSubCategory> ilistSubCategory = YnDaoHelper.GetInstance().nHibernateHelper.Find<AscmMaterialSubCategory>(sql); if (ilistSubCategory != null && ilistSubCategory.Count > 0) { foreach (AscmMaterialSubCategory ascmMaterialSubCategory in ilistSubCategory) { if (!string.IsNullOrEmpty(ascmMaterialSubCategory.zMtlCategoryStatus)) { ascmMaterialItem.zMtlCategoryStatus = ascmMaterialSubCategory.zMtlCategoryStatus; } if (!string.IsNullOrEmpty(ascmMaterialSubCategory.dMtlCategoryStatus)) { ascmMaterialItem.dMtlCategoryStatus = ascmMaterialSubCategory.dMtlCategoryStatus; } if (!string.IsNullOrEmpty(ascmMaterialSubCategory.wMtlCategoryStatus)) { ascmMaterialItem.wMtlCategoryStatus = ascmMaterialSubCategory.wMtlCategoryStatus; } } } } AscmMaterialSubCategory subCategory = AscmMaterialSubCategoryService.GetInstance().GetId(combinationCode); if (subCategory != null) { ascmMaterialItem.subCategoryId = subCategory.id; ascmMaterialItem.isFlag = 1; AscmMaterialItemService.GetInstance().Update(ascmMaterialItem); } } } #endregion } } jsonObjectResult.result = true; jsonObjectResult.message = "已完成物料大类、小类及物料信息维护!"; } catch (Exception ex) { jsonObjectResult.result = false; jsonObjectResult.message = ex.Message; } string sReturn = JsonConvert.SerializeObject(jsonObjectResult); return Content(sReturn); }
public ContentResult AllocateLogisticsTaskDelete(string releaseHeaderIds) { JsonObjectResult jsonObjectResult = new JsonObjectResult(); string userName = string.Empty; if (User.Identity.IsAuthenticated) { userName = User.Identity.Name; } try { string whereOther = "", whereQueryWord = ""; if (!string.IsNullOrEmpty(releaseHeaderIds)) { whereQueryWord = "id in (" + releaseHeaderIds + ")"; whereOther = YnBaseClass2.Helper.StringHelper.SqlWhereAndAdd(whereOther, whereQueryWord); } whereQueryWord = "taskId like '%L%'"; whereOther = YnBaseClass2.Helper.StringHelper.SqlWhereAndAdd(whereOther, whereQueryWord); //whereQueryWord = "IdentificationId = " + AscmGetMaterialTask.IdentificationIdDefine.ls.ToString(); //whereOther = YnBaseClass2.Helper.StringHelper.SqlWhereAndAdd(whereOther, whereQueryWord); List<AscmGetMaterialTask> list = AscmGetMaterialTaskService.GetInstance().GetList(null, "", "", "", whereOther); if (list == null || list.Count == 0) throw new Exception("非临时任务不允许删除!"); AscmGetMaterialTaskService.GetInstance().Delete(list); jsonObjectResult.result = true; jsonObjectResult.message = ""; } catch (Exception ex) { jsonObjectResult.result = false; jsonObjectResult.message = ex.Message; } string sReturn = JsonConvert.SerializeObject(jsonObjectResult); return Content(sReturn); }
public ActionResult MaterialImport(HttpPostedFileBase fileImport) { JsonObjectResult jsonObjectResult = new JsonObjectResult(); string sError = ""; DataTable dt = new DataTable(); int colsCount = 0; colsCount = int.TryParse(AscmCommonHelperService.MaterialStockFormatImportParam.ToString(), out colsCount) ? colsCount : 6; StringBuilder sb = new StringBuilder(); string userName = string.Empty; if (User.Identity.IsAuthenticated) { userName = User.Identity.Name; } try { for (int i = 0; i < colsCount; i++) { dt.Columns.Add("第" + i.ToString() + "列"); } if (fileImport != null) { List<AscmMaterialItem> listAscmMaterialItem = new List<AscmMaterialItem>(); using (Stream stream = fileImport.InputStream) { NPOI.SS.UserModel.IWorkbook wb = NPOI.SS.UserModel.WorkbookFactory.Create(stream); ISheet sheet = wb.GetSheet("Sheet1"); IEnumerator rows = sheet.GetRowEnumerator(); while (rows.MoveNext()) { DataRow dr = dt.NewRow(); NPOI.SS.UserModel.IRow row = (NPOI.SS.UserModel.IRow)rows.Current; if (row.RowNum != 0) { List<NPOI.SS.UserModel.ICell> iCellList = new List<NPOI.SS.UserModel.ICell>(); for (int i = 0; i < colsCount; i++) { NPOI.SS.UserModel.ICell iCell = row.GetCell(i, MissingCellPolicy.CREATE_NULL_AS_BLANK); iCellList.Add(iCell); } for (int i = 0; i < dt.Columns.Count; i++) { if (iCellList[i] != null) dr[i] = iCellList[i].ToString(); } dt.Rows.Add(dr); } sb.Append(dr[0].ToString()); } } if (dt.Rows.Count > 0) { foreach (DataRow dr in dt.Rows) { object obj = YnDaoHelper.GetInstance().nHibernateHelper.GetObject("select count(*) from AscmMaterialItem where docNumber = '" + dr[0].ToString() + "'"); if (obj == null) throw new Exception("查询异常!"); int iCount = 0; if (int.TryParse(obj.ToString(), out iCount) && iCount > 0) { List<AscmMaterialItem> tempList = AscmMaterialItemService.GetInstance().GetList("from AscmMaterialItem where docNumber = '" + dr[0].ToString() + "'"); if (tempList != null && tempList.Count > 0) { foreach (AscmMaterialItem ascmMaterialItem in tempList) { string newError = ""; if (dr[3].ToString() == MtlCategoryStatusDefine.DisplayText(MtlCategoryStatusDefine.inStock)) ascmMaterialItem.zMtlCategoryStatus = MtlCategoryStatusDefine.inStock; else if (dr[3].ToString() == MtlCategoryStatusDefine.DisplayText(MtlCategoryStatusDefine.mixStock)) ascmMaterialItem.zMtlCategoryStatus = MtlCategoryStatusDefine.mixStock; else if (dr[3].ToString() == MtlCategoryStatusDefine.DisplayText(MtlCategoryStatusDefine.preStock)) ascmMaterialItem.zMtlCategoryStatus = MtlCategoryStatusDefine.preStock; else if (string.IsNullOrEmpty(dr[3].ToString())) ascmMaterialItem.wMtlCategoryStatus = ""; else if (!string.IsNullOrEmpty(dr[3].ToString())) newError += "物料编码[" + ascmMaterialItem.docNumber + "]总装备料形式书写不正确:" + dr[3].ToString() + "<br />"; if (!string.IsNullOrEmpty(newError)) { sError += newError; continue; } if (dr[4].ToString() == MtlCategoryStatusDefine.DisplayText(MtlCategoryStatusDefine.inStock)) ascmMaterialItem.dMtlCategoryStatus = MtlCategoryStatusDefine.inStock; else if (dr[4].ToString() == MtlCategoryStatusDefine.DisplayText(MtlCategoryStatusDefine.mixStock)) ascmMaterialItem.dMtlCategoryStatus = MtlCategoryStatusDefine.mixStock; else if (dr[4].ToString() == MtlCategoryStatusDefine.DisplayText(MtlCategoryStatusDefine.preStock)) ascmMaterialItem.dMtlCategoryStatus = MtlCategoryStatusDefine.preStock; else if (string.IsNullOrEmpty(dr[4].ToString())) ascmMaterialItem.wMtlCategoryStatus = ""; else if (!string.IsNullOrEmpty(dr[4].ToString())) newError += "物料编码[" + ascmMaterialItem.docNumber + "]电装备料形式书写不正确:" + dr[4].ToString() + "<br />"; if (!string.IsNullOrEmpty(newError)) { sError += newError; continue; } if (dr[5].ToString() == MtlCategoryStatusDefine.DisplayText(MtlCategoryStatusDefine.inStock)) ascmMaterialItem.wMtlCategoryStatus = MtlCategoryStatusDefine.inStock; else if (dr[5].ToString() == MtlCategoryStatusDefine.DisplayText(MtlCategoryStatusDefine.mixStock)) ascmMaterialItem.wMtlCategoryStatus = MtlCategoryStatusDefine.mixStock; else if (dr[5].ToString() == MtlCategoryStatusDefine.DisplayText(MtlCategoryStatusDefine.preStock)) ascmMaterialItem.wMtlCategoryStatus = MtlCategoryStatusDefine.preStock; else if (string.IsNullOrEmpty(dr[5].ToString())) ascmMaterialItem.wMtlCategoryStatus = ""; else if (!string.IsNullOrEmpty(dr[5].ToString())) newError += "物料编码[" + ascmMaterialItem.docNumber + "]其他备料形式书写不正确:" + dr[5].ToString() + "<br />"; if (!string.IsNullOrEmpty(newError)) { sError += newError; continue; } ascmMaterialItem.modifyTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm"); ascmMaterialItem.modifyUser = userName; listAscmMaterialItem.Add(ascmMaterialItem); } } } else { sError += "未找到对应的物料编码:" + dr[0].ToString() + "<br />"; } } using (ITransaction tx = YnDaoHelper.GetInstance().nHibernateHelper.GetCurrentSession().BeginTransaction()) { try { if (listAscmMaterialItem != null && listAscmMaterialItem.Count > 0) { YnDaoHelper.GetInstance().nHibernateHelper.UpdateList(listAscmMaterialItem); } tx.Commit(); sError += "【成功更新" + listAscmMaterialItem.Count.ToString() + "条记录!】"; jsonObjectResult.message = sError; jsonObjectResult.result = true; } catch (Exception ex) { tx.Rollback(); sError += ex.Message; } } } } } catch (Exception ex) { jsonObjectResult.result = false; jsonObjectResult.message += ex.Message; } string sReturn = JsonConvert.SerializeObject(jsonObjectResult); return Content(sReturn); }
public ContentResult RfidSave(string rfidStart, string rfidEnd, string bindTypeDefine) { JsonObjectResult jsonObjectResult = new JsonObjectResult(); try { if (string.IsNullOrEmpty(rfidStart) || string.IsNullOrEmpty(rfidEnd)) throw new Exception("RFID号码段录入错误!"); long _rfidStart = 0; long _rfidEnd = 0; long.TryParse(rfidStart, out _rfidStart); long.TryParse(rfidEnd, out _rfidEnd); if (_rfidStart == 0 || _rfidEnd == 0 || _rfidStart > _rfidEnd) throw new Exception("RFID号码段录入错误!"); //if (_rfidEnd - _rfidStart + 1 != giftCardPublishMain_Model.number) // throw new Exception("礼卡号码段与录入数量不匹配!"); if(_rfidEnd - _rfidStart+1>500) throw new Exception("一次添加不能超过500!"); if (string.IsNullOrEmpty(bindTypeDefine)) throw new Exception("必须选择RFID类型!"); List<AscmRfid> listAscmRfid_New = new List<AscmRfid>(); List<AscmRfid> listAscmRfid = AscmRfidService.GetInstance().GetList(" from AscmRfid where id>='" + rfidStart + "' and id<='" + rfidEnd + "'"); for (long code = _rfidStart; code <= _rfidEnd; code++) { string sCode = string.Format("{0:" + YnBaseClass2.Helper.StringHelper.Repeat('0', rfidStart.Trim().Length) + "}", code); AscmRfid ascmRfid = listAscmRfid.Find(P => P.id == sCode); if (ascmRfid != null) throw new Exception("RFID已经存在[" + sCode + "]!"); ascmRfid = new AscmRfid(); ascmRfid.id = sCode; ascmRfid.bindType = bindTypeDefine; ascmRfid.bindId = ""; ascmRfid.status = ""; listAscmRfid_New.Add(ascmRfid); } AscmRfidService.GetInstance().Save(listAscmRfid_New); jsonObjectResult.result = true; jsonObjectResult.message = ""; //jsonObjectResult.id = ascmEmployeeCar.id.ToString(); //jsonObjectResult.entity = ascmEmployeeCar; } catch (Exception ex) { jsonObjectResult.message = ex.Message; } string sReturn = JsonConvert.SerializeObject(jsonObjectResult); return Content(sReturn); }
public ContentResult SaveJob(AscmJob ascmJob_Model, string id, string argumentJson) { JsonObjectResult jsonObjectResult = new JsonObjectResult(); try { if (ascmJob_Model == null) throw new Exception("传参错误!"); if (ascmJob_Model.jobName == null || ascmJob_Model.jobName.Trim() == "") throw new Exception("作业名称不能为空!"); //bool isAdd = (id == null || id.Trim() == ""); bool isAdd = false; string jobName = ascmJob_Model.jobName.Trim(); AscmJob ascmJob = AscmJobService.GetInstance().Get(jobName); if (ascmJob == null) { ascmJob = new AscmJob(); ascmJob.jobName = jobName; isAdd = true; } ascmJob.comments = ascmJob_Model.comments.Trim(); ascmJob.enabled = ascmJob_Model.enabled; ascmJob.autoDrop = ascmJob_Model.autoDrop; ascmJob.startDate = ascmJob_Model.startDate; JobRepeatInterval jobRepeatInterval = new JobRepeatInterval( ascmJob_Model.freq, ascmJob_Model.interval, ascmJob_Model.byMonthDay, ascmJob_Model.byDay, ascmJob_Model.byTime); ascmJob.repeatInterval = jobRepeatInterval.ToString(); ascmJob.jobAction = ascmJob_Model.jobAction; List<AscmProcedureArgument> listProcedureArgument = null; if (!string.IsNullOrEmpty(argumentJson)) listProcedureArgument = JsonConvert.DeserializeObject<List<AscmProcedureArgument>>(argumentJson); //if (!string.IsNullOrEmpty(argumentJson)) //{ // List<AscmProcedureArgument> listProcedureArgument_Model = JsonConvert.DeserializeObject<List<AscmProcedureArgument>>(argumentJson); // if (listProcedureArgument_Model != null) // { // listProcedureArgument = new List<AscmProcedureArgument>(); // foreach (AscmProcedureArgument ascmProcedureArgument in listProcedureArgument_Model) // { // if (!string.IsNullOrEmpty(ascmProcedureArgument.argumentName)) // listProcedureArgument.Add(ascmProcedureArgument); // } // } //} ascmJob.listProcedureArgument = listProcedureArgument; if (isAdd) AscmJobService.GetInstance().CreateJob(ascmJob); else AscmJobService.GetInstance().UpdateJob(ascmJob); jsonObjectResult.result = true; jsonObjectResult.id = jobName; jsonObjectResult.message = isAdd ? "作业创建成功!" : "作业修改成功!"; } catch (Exception ex) { jsonObjectResult.message = ex.Message; } string sReturn = JsonConvert.SerializeObject(jsonObjectResult); return Content(sReturn); }
public ContentResult UnMarkTask(int? id, int? wipEntityId) { JsonObjectResult jsonObjectResult = new JsonObjectResult(); List<AscmGetMaterialTask> list = null; List<AscmMarkTaskLog> listAscmMarkTaskLog = null; string userName = string.Empty; if (User.Identity.IsAuthenticated) { userName = User.Identity.Name; } try { if (id.HasValue && wipEntityId.HasValue) { object object1 = YnDaoHelper.GetInstance().nHibernateHelper.GetObject("select count(*) from AscmMarkTaskLog where wipEntityId = " + wipEntityId.ToString() + " and taskId = " + id.ToString() + " and isMark = 1"); if (object1 == null) throw new Exception("查询异常!"); int iCount = 0; if (int.TryParse(object1.ToString(), out iCount) && iCount == 0) throw new Exception("该标记不存在!"); string whereOther = "", whereQueryWord = ""; whereQueryWord = "taskId = " + id.Value.ToString(); whereOther = YnBaseClass2.Helper.StringHelper.SqlWhereAndAdd(whereOther, whereQueryWord); whereQueryWord = "wipEntityId = " + wipEntityId.Value.ToString(); whereOther = YnBaseClass2.Helper.StringHelper.SqlWhereAndAdd(whereOther, whereQueryWord); whereQueryWord = "isMark = 1"; whereOther = YnBaseClass2.Helper.StringHelper.SqlWhereAndAdd(whereOther, whereQueryWord); whereQueryWord = "markType = 'NONAUTO'"; whereOther = YnBaseClass2.Helper.StringHelper.SqlWhereAndAdd(whereOther, whereQueryWord); listAscmMarkTaskLog = AscmMarkTaskLogService.GetInstance().GetList(null, "", "", "", whereOther, false, false); if (listAscmMarkTaskLog == null || listAscmMarkTaskLog.Count == 0) throw new Exception("标记不存在!"); if (listAscmMarkTaskLog != null && listAscmMarkTaskLog.Count > 0) { foreach (AscmMarkTaskLog ascmMarkTaskLog in listAscmMarkTaskLog) { ascmMarkTaskLog.isMark = 0; ascmMarkTaskLog.modifyUser = userName; ascmMarkTaskLog.modifyTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm"); AscmGetMaterialTask ascmGetMaterialTask = AscmGetMaterialTaskService.GetInstance().Get(ascmMarkTaskLog.taskId); if (ascmGetMaterialTask.relatedMark.IndexOf(",") > -1) { if (ascmGetMaterialTask.relatedMark.IndexOf(ascmMarkTaskLog.id.ToString()) > -1) { string markString = ascmGetMaterialTask.relatedMark.Replace(ascmMarkTaskLog.id.ToString(), ""); string[] markArray = markString.Split(','); string newMarkString = string.Empty; foreach (string item in markArray) { if (!string.IsNullOrEmpty(newMarkString)) newMarkString += ","; if (!string.IsNullOrEmpty(item)) newMarkString += item; } ascmGetMaterialTask.relatedMark = newMarkString; } } else { if (ascmGetMaterialTask.relatedMark == ascmMarkTaskLog.id.ToString()) { ascmGetMaterialTask.relatedMark = ""; } } ascmGetMaterialTask.modifyUser = userName; ascmGetMaterialTask.modifyTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm"); if (list == null) list = new List<AscmGetMaterialTask>(); list.Add(ascmGetMaterialTask); } } if (list == null || list.Count == 0) throw new Exception("取消标记失败!"); //执行事务 ISession session = YnDaoHelper.GetInstance().nHibernateHelper.GetCurrentSession(); session.Clear(); using (ITransaction tx = session.BeginTransaction()) { try { //更新(取消)任务标记 if (list != null) AscmGetMaterialTaskService.GetInstance().Update(list); //更新标记 if (listAscmMarkTaskLog != null) AscmMarkTaskLogService.GetInstance().Update(listAscmMarkTaskLog); } catch (Exception ex) { tx.Rollback(); YnBaseClass2.Helper.LogHelper.GetLog().Error("标记失败(Mark AscmMarkTaskLog)", ex); } } jsonObjectResult.result = true; jsonObjectResult.message = ""; } } catch (Exception ex) { jsonObjectResult.result = false; jsonObjectResult.message = ex.Message; } string sReturn = JsonConvert.SerializeObject(jsonObjectResult); return Content(sReturn); }
public ActionResult SupplierMaterialImport(HttpPostedFileBase fileImport, int? supplierId) { JsonObjectResult jsonObjectResult = new JsonObjectResult(); string sError = ""; try { if (!supplierId.HasValue) throw new Exception("供应商ID传值错误!"); if (fileImport != null) { string userName = string.Empty; if (User.Identity.IsAuthenticated) userName = User.Identity.Name; //定义索引 int documentIndex = 1; using (Stream stream = fileImport.InputStream) { List<AscmMaterialItem> listAscmMaterialItem = null; List<AscmSupplierMaterialLink> listAscmSupplierMaterialLink = new List<AscmSupplierMaterialLink>(); List<AscmSupplierMaterialLink> listLink = AscmSupplierMaterialLinkService.GetInstance().GetList(supplierId.Value); int maxId = YnDaoHelper.GetInstance().nHibernateHelper.GetMaxId("select max(id) from AscmSupplierMaterialLink"); IWorkbook wb = WorkbookFactory.Create(stream); ISheet sheet = wb.GetSheet("Sheet1"); System.Collections.IEnumerator rows = sheet.GetRowEnumerator(); string docNumbers = string.Empty;//对物料进行匹配,不需单引号 string docNumbersIn = string.Empty;//查询物料,需要对每个字符串加单引号 while (rows.MoveNext()) { sError = "【未成功更新数据】<br>"; IRow row = (IRow)rows.Current; if (row.RowNum != 0) { ICell buildingCell = row.GetCell(documentIndex, MissingCellPolicy.CREATE_NULL_AS_BLANK); if (buildingCell != null) { if (!string.IsNullOrEmpty(docNumbers)) docNumbers += ","; docNumbers += buildingCell.ToString().Trim(); if (!string.IsNullOrEmpty(docNumbersIn)) docNumbersIn += ","; docNumbersIn += "'" + buildingCell.ToString().Trim() + "'"; } else { sError += " [" + row.RowNum + 1 + "]行" + "无法识别;<br>"; } } } if (!string.IsNullOrEmpty(docNumbersIn)) { string sql = " from AscmMaterialItem where "; string sSql = string.Empty; var sDocNumbersIn = docNumbersIn.Split(',').Distinct(); var iCount = sDocNumbersIn.Count(); if (iCount > 900) { string ids = string.Empty; for (int i = 0; i < iCount; i++) { if (!string.IsNullOrEmpty(ids)) ids += ","; ids += sDocNumbersIn.ElementAt(i); if ((i + 1) % 900 == 0 || (i + 1) == iCount) { if (!string.IsNullOrEmpty(sSql)) sSql += " or "; sSql += "docNumber in (" + ids + ")"; ids = string.Empty; } } } else sSql = "docNumber in (" + docNumbersIn + ")"; sql = sql + sSql; listAscmMaterialItem = AscmMaterialItemService.GetInstance().GetList(sql, true); } if (listAscmMaterialItem != null && listAscmMaterialItem.Count() > 0) { var sDocNumbers = docNumbers.Split(',').Distinct(); AscmMaterialItem ascmMaterialItem = null; int iRow = 0; foreach (string docNumber in sDocNumbers) { iRow++; ascmMaterialItem = listAscmMaterialItem.Find(item => item.docNumber == docNumber); if (ascmMaterialItem != null) { AscmSupplierMaterialLink ascmSupplierMaterialLink = null; if (listLink != null && listLink.Count() > 0) ascmSupplierMaterialLink = listLink.Find(item => item.materialId == ascmMaterialItem.id); if (ascmSupplierMaterialLink == null) { AscmSupplierMaterialLink ascmLink = new AscmSupplierMaterialLink(); ascmLink.id = ++maxId; ascmLink.materialId = ascmMaterialItem.id; ascmLink.modifyTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); ascmLink.modifyUser = userName; ascmLink.supplierId = supplierId.Value; listAscmSupplierMaterialLink.Add(ascmLink); } } else { sError += " [" + docNumber + "]" + "未找到匹配物料;<br>"; } } } else { sError += " " + "未找到匹配物料;<br>"; } if (listAscmSupplierMaterialLink != null && listAscmSupplierMaterialLink.Count() > 0) { AscmSupplierMaterialLinkService.GetInstance().Save(listAscmSupplierMaterialLink); sError += "【成功更新" + listAscmSupplierMaterialLink.Count() + "条】"; } jsonObjectResult.message = sError; jsonObjectResult.result = true; } #region //List<AscmSupplierMaterialLink> listAscmSupplierMaterialLink = null; //List<AscmSupplierMaterialLink> listLink=AscmSupplierMaterialLinkService.GetInstance().GetList(supplierId.Value); //List<AscmMaterialItem> listAscmMaterialItem=AscmMaterialItemService.GetInstance().GetList(" from AscmMaterialItem"); //int maxId = YnDaoHelper.GetInstance().nHibernateHelper.GetMaxId("select max(id) from AscmSupplierMaterialLink"); //using (Stream stream = fileImport.InputStream) //{ // listAscmSupplierMaterialLink = new List<AscmSupplierMaterialLink>(); // IWorkbook wb = WorkbookFactory.Create(stream); // ISheet sheet = wb.GetSheet("Sheet1"); // System.Collections.IEnumerator rows = sheet.GetRowEnumerator(); // while (rows.MoveNext()) // { // sError = "【未成功更新数据】<br>"; // IRow row = (IRow)rows.Current; // if (row.RowNum != 0) // { // ICell buildingCell = row.GetCell(documentIndex, MissingCellPolicy.CREATE_NULL_AS_BLANK); // string docNumber=string.Empty; // if (buildingCell != null) // { // docNumber = buildingCell.ToString().Trim(); // AscmMaterialItem ascmMaterialItem = listAscmMaterialItem.Find(item => item.docNumber == docNumber); // if (ascmMaterialItem != null) // { // AscmSupplierMaterialLink ascmSupplierMaterialLink = null; // if(listLink!=null&&listLink.Count()>0) // ascmSupplierMaterialLink = listLink.Find(item => item.materialId == ascmMaterialItem.id); // if (ascmSupplierMaterialLink == null) // { // AscmSupplierMaterialLink ascmLink = new AscmSupplierMaterialLink(); // ascmLink.id = ++maxId; // ascmLink.materialId = ascmMaterialItem.id; // ascmLink.modifyTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); // ascmLink.modifyUser = userName; // ascmLink.supplierId = supplierId.Value; // listAscmSupplierMaterialLink.Add(ascmLink); // } // } // else // { // sError += " [" + row.RowNum + 1 + "]行" + "未匹配到相应物料;<br>"; // } // } // else // { // sError += " [" + row.RowNum + 1 + "]行" + "未识别到物料编码;<br>"; // } // } // } // if (listAscmSupplierMaterialLink != null && listAscmSupplierMaterialLink.Count() > 0) // { // AscmSupplierMaterialLinkService.GetInstance().Save(listAscmSupplierMaterialLink); // sError += "【成功更新" + listAscmSupplierMaterialLink.Count() + "条】"; // jsonObjectResult.message = sError; // jsonObjectResult.result = true; // } //} #endregion } } catch (Exception ex) { jsonObjectResult.message += ex.Message; } string sReturn = JsonConvert.SerializeObject(jsonObjectResult); return Content(sReturn); }
public ContentResult BatchMaterialStockFormatSave(AscmMaterialItem ascmMaterialItem_Model) { string userName = string.Empty; if (User.Identity.IsAuthenticated) { userName = User.Identity.Name; } JsonObjectResult jsonObjectReuslt = new JsonObjectResult(); List<AscmMaterialItem> list = null; try { if (string.IsNullOrEmpty(ascmMaterialItem_Model.sDocnumber) || string.IsNullOrEmpty(ascmMaterialItem_Model.eDocnumber)) throw new Exception("编码段不能为空!"); string whereOther = "", whereQueryWord = ""; if (!string.IsNullOrEmpty(ascmMaterialItem_Model.wipSupplyType.ToString()) && ascmMaterialItem_Model.wipSupplyType.ToString() != "0") { whereQueryWord = "wipSupplyType = " + ascmMaterialItem_Model.wipSupplyType.ToString(); whereOther = YnBaseClass2.Helper.StringHelper.SqlWhereAndAdd(whereOther, whereQueryWord); } if (!string.IsNullOrEmpty(ascmMaterialItem_Model.sDocnumber) && !string.IsNullOrEmpty(ascmMaterialItem_Model.eDocnumber)) { whereQueryWord = "docNumber >= '" + ascmMaterialItem_Model.sDocnumber + "'"; whereOther = YnBaseClass2.Helper.StringHelper.SqlWhereAndAdd(whereOther, whereQueryWord); whereQueryWord = "docNumber <= '" + ascmMaterialItem_Model.eDocnumber + "'"; whereOther = YnBaseClass2.Helper.StringHelper.SqlWhereAndAdd(whereOther, whereQueryWord); } list = AscmMaterialItemService.GetInstance().GetList(null, "", "", "", whereOther, false); if (list != null && list.Count > 0) { foreach (AscmMaterialItem ascmMaterialItem in list) { if (!string.IsNullOrEmpty(ascmMaterialItem_Model.zMtlCategoryStatus)) { ascmMaterialItem.zMtlCategoryStatus = ascmMaterialItem_Model.zMtlCategoryStatus; } if (!string.IsNullOrEmpty(ascmMaterialItem_Model.dMtlCategoryStatus)) { ascmMaterialItem.dMtlCategoryStatus = ascmMaterialItem_Model.dMtlCategoryStatus; } if (!string.IsNullOrEmpty(ascmMaterialItem_Model.wMtlCategoryStatus)) { ascmMaterialItem.wMtlCategoryStatus = ascmMaterialItem_Model.wMtlCategoryStatus; } ascmMaterialItem.modifyTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm"); ascmMaterialItem.modifyUser = userName; } AscmMaterialItemService.GetInstance().Update(list); } jsonObjectReuslt.result = true; jsonObjectReuslt.message = "批量维护成功!"; } catch (Exception ex) { jsonObjectReuslt.result = false; jsonObjectReuslt.message = ex.Message; } string sReturn = JsonConvert.SerializeObject(jsonObjectReuslt); return Content(sReturn); }
public ActionResult DropJob(string jobName) { JsonObjectResult jsonObjectResult = new JsonObjectResult(); try { if (jobName == null || jobName.Trim() == "") throw new Exception("请选择要删除的作业!"); AscmJobService.GetInstance().DropJob(jobName.Trim()); jsonObjectResult.result = true; jsonObjectResult.message = "作业【" + jobName.Trim() + "】删除成功!"; } catch (Exception ex) { jsonObjectResult.message = ex.Message; } return Json(jsonObjectResult, JsonRequestBehavior.AllowGet); }
public ContentResult ChoiceMaterialStockFormatSave(string releaseHeaderIds, string zmtlCategoryStatus, string dmtlCategoryStatus, string wmtlCategoryStatus) { string userName = string.Empty; if (User.Identity.IsAuthenticated) { userName = User.Identity.Name; } JsonObjectResult jsonObjectReuslt = new JsonObjectResult(); List<AscmMaterialItem> list = null; try { string whereOther = "", whereQueryWord = ""; if (!string.IsNullOrEmpty(releaseHeaderIds)) { whereQueryWord = "id in (" + releaseHeaderIds + ")"; whereOther = YnBaseClass2.Helper.StringHelper.SqlWhereAndAdd(whereOther, whereQueryWord); } list = AscmMaterialItemService.GetInstance().GetList(null, "", "", "", whereOther, false); if (list != null && list.Count > 0) { foreach (AscmMaterialItem ascmMaterialItem in list) { if (!string.IsNullOrEmpty(zmtlCategoryStatus)) { ascmMaterialItem.zMtlCategoryStatus = zmtlCategoryStatus; } if (!string.IsNullOrEmpty(dmtlCategoryStatus)) { ascmMaterialItem.dMtlCategoryStatus = dmtlCategoryStatus; } if (!string.IsNullOrEmpty(wmtlCategoryStatus)) { ascmMaterialItem.wMtlCategoryStatus = wmtlCategoryStatus; } ascmMaterialItem.modifyTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm"); ascmMaterialItem.modifyUser = userName; } AscmMaterialItemService.GetInstance().Update(list); } jsonObjectReuslt.result = true; jsonObjectReuslt.message = "批量维护成功!"; } catch (Exception ex) { jsonObjectReuslt.result = false; jsonObjectReuslt.message = ex.Message; } string sReturn = JsonConvert.SerializeObject(jsonObjectReuslt); return Content(sReturn); }
public ContentResult EmployeeCarSave(AscmEmployeeCar ascmEmployeeCar_Model, int? id) { JsonObjectResult jsonObjectResult = new JsonObjectResult(); try { AscmEmployeeCar ascmEmployeeCar = null; if (id.HasValue) { ascmEmployeeCar = AscmEmployeeCarService.GetInstance().Get(id.Value); } else { ascmEmployeeCar = new AscmEmployeeCar(); } if (ascmEmployeeCar == null) throw new Exception("保存员工车辆基本信息失败!"); if (ascmEmployeeCar_Model.plateNumber == null || ascmEmployeeCar_Model.plateNumber.Trim() == "") throw new Exception("员工车辆车牌号不能为空!"); if (ascmEmployeeCar_Model.rfid.Length != 10) { throw new Exception("rfid编号可能有错误【" + ascmEmployeeCar_Model.rfid.Trim() + "】,请检查,请输入后4位或后6位!"); } //if (ascmEmployeeCar_Model.employeeId==0) // throw new Exception("必须选择输入员工!"); ascmEmployeeCar.plateNumber = ascmEmployeeCar_Model.plateNumber.Trim(); ascmEmployeeCar.spec = ascmEmployeeCar_Model.spec; ascmEmployeeCar.color = ascmEmployeeCar_Model.color; ascmEmployeeCar.seatCount = ascmEmployeeCar_Model.seatCount; ascmEmployeeCar.rfid = ascmEmployeeCar_Model.rfid.Trim(); ascmEmployeeCar.memo = ascmEmployeeCar_Model.memo; //ascmEmployeeCar.employeeId = ascmEmployeeCar_Model.employeeId; ascmEmployeeCar.employeeDocNumber = ascmEmployeeCar_Model.employeeDocNumber; if (!string.IsNullOrEmpty(ascmEmployeeCar.employeeDocNumber)) ascmEmployeeCar.employeeDocNumber = ascmEmployeeCar.employeeDocNumber.Trim(); ascmEmployeeCar.employeeName = ascmEmployeeCar_Model.employeeName; if (!string.IsNullOrEmpty(ascmEmployeeCar.employeeName)) ascmEmployeeCar.employeeName = ascmEmployeeCar.employeeName.Trim(); ascmEmployeeCar.employeeSex = ascmEmployeeCar_Model.employeeSex; if (!string.IsNullOrEmpty(ascmEmployeeCar.employeeSex)) ascmEmployeeCar.employeeSex = ascmEmployeeCar.employeeSex.Trim(); ascmEmployeeCar.employeeIdNumber = ascmEmployeeCar_Model.employeeIdNumber; if (!string.IsNullOrEmpty(ascmEmployeeCar.employeeIdNumber)) ascmEmployeeCar.employeeIdNumber = ascmEmployeeCar.employeeIdNumber.Trim(); ascmEmployeeCar.employeeOfficeTel = ascmEmployeeCar_Model.employeeOfficeTel; ascmEmployeeCar.employeeMobileTel = ascmEmployeeCar_Model.employeeMobileTel; ascmEmployeeCar.exemption = ascmEmployeeCar_Model.exemption; ascmEmployeeCar.employeeLevel = ascmEmployeeCar_Model.employeeLevel; AscmRfid ascmRfid_Old = null; AscmRfid ascmRfid_New_Update = null; AscmRfid ascmRfid_New_Save = null; bool _new = true; if (!id.HasValue) { object object1 = YnDaoHelper.GetInstance().nHibernateHelper.GetObject("select count(*) from AscmEmployeeCar where plateNumber='" + ascmEmployeeCar_Model.plateNumber.Trim() + "'"); if (object1 == null) throw new Exception("查询异常!"); int iCount = 0; if (int.TryParse(object1.ToString(), out iCount) && iCount > 0) throw new Exception("已经存在此员工车辆车牌号【" + ascmEmployeeCar_Model.plateNumber.Trim() + "】!"); if (!string.IsNullOrEmpty(ascmEmployeeCar_Model.rfid)) { object1 = YnDaoHelper.GetInstance().nHibernateHelper.GetObject("select count(*) from AscmEmployeeCar where rfid='" + ascmEmployeeCar_Model.rfid.Trim() + "'"); if (object1 == null) throw new Exception("查询异常!"); //int iCount = 0; if (int.TryParse(object1.ToString(), out iCount) && iCount > 0) throw new Exception("已经分配此车辆RFID【" + ascmEmployeeCar_Model.rfid.Trim() + "】!"); } int maxId = YnDaoHelper.GetInstance().nHibernateHelper.GetMaxId("select max(id) from AscmEmployeeCar"); ascmEmployeeCar.id = maxId+1; //AscmEmployeeCarService.GetInstance().Save(ascmEmployeeCar); } else { _new = false; if (ascmEmployeeCar.rfid!=null) ascmRfid_Old = AscmRfidService.GetInstance().Get(ascmEmployeeCar.rfid.Trim()); object object1 = YnDaoHelper.GetInstance().nHibernateHelper.GetObject("select count(*) from AscmEmployeeCar where plateNumber='" + ascmEmployeeCar_Model.plateNumber.Trim() + "' and id<>" + id.Value + ""); if (object1 == null) throw new Exception("查询异常!"); int iCount = 0; if (int.TryParse(object1.ToString(), out iCount) && iCount > 0) throw new Exception("已经存在此员工车辆车牌号【" + ascmEmployeeCar_Model.plateNumber.Trim() + "】!"); if (!string.IsNullOrEmpty(ascmEmployeeCar_Model.rfid)) { object1 = YnDaoHelper.GetInstance().nHibernateHelper.GetObject("select count(*) from AscmEmployeeCar where rfid='" + ascmEmployeeCar_Model.rfid.Trim() + "' and id<>" + id.Value + ""); if (object1 == null) throw new Exception("查询异常!"); //int iCount = 0; if (int.TryParse(object1.ToString(), out iCount) && iCount > 0) throw new Exception("已经分配此车辆RFID【" + ascmEmployeeCar_Model.rfid.Trim() + "】!"); } //AscmEmployeeCarService.GetInstance().Update(ascmEmployeeCar); } ascmRfid_New_Update = AscmRfidService.GetInstance().Get(ascmEmployeeCar.rfid.Trim()); if (ascmRfid_Old != null && ascmRfid_New_Update != null) { if (ascmRfid_Old.id == ascmRfid_New_Update.id) { ascmRfid_Old = null; } } if (ascmRfid_Old != null) { ascmRfid_Old.bindType = AscmRfid.BindTypeDefine.employeeCar; ascmRfid_Old.bindId = ""; ascmRfid_Old.status = AscmRfid.StatusDefine.none; //ascmRfid_Old.modifyTime = dtServerTime.ToString("yyyy-MM-dd HH:mm:ss"); } if (ascmRfid_New_Update != null) { ascmRfid_New_Update.bindType = AscmRfid.BindTypeDefine.employeeCar; ascmRfid_New_Update.bindId = ascmEmployeeCar.id.ToString(); ascmRfid_New_Update.status = AscmRfid.StatusDefine.inUse; //ascmRfid_New_Update.modifyTime = dtServerTime.ToString("yyyy-MM-dd HH:mm:ss"); } else { ascmRfid_New_Save = new AscmRfid(); ascmRfid_New_Save.id = ascmEmployeeCar.rfid; ascmRfid_New_Save.createUser = ""; //ascmRfid_New_Save.createTime = dtServerTime.ToString("yyyy-MM-dd HH:mm:ss"); //ascmRfid_New_Save.modifyTime = dtServerTime.ToString("yyyy-MM-dd HH:mm:ss"); ascmRfid_New_Save.bindType = AscmRfid.BindTypeDefine.employeeCar; ascmRfid_New_Save.bindId = ascmEmployeeCar.id.ToString(); ascmRfid_New_Save.status = AscmRfid.StatusDefine.inUse; } /* if (string.IsNullOrEmpty(ascmEmployeeCar_Model.rfid)) { ascmEmployeeCar.rfid = ""; //取消绑定 if (ascmRfid_Old != null) { ascmRfid_Old.bindId = ""; ascmRfid_Old.status = ""; } } else { //增加绑定 ascmRfid_New = AscmRfidService.GetInstance().Get(ascmEmployeeCar_Model.rfid.Trim()); if (ascmRfid_New == null) throw new Exception("RFID标签号码不存在!"); if (ascmRfid_New.bindType != AscmRfid.BindTypeDefine.employeeCar) throw new Exception("请选择[" + AscmRfid.BindTypeDefine.DisplayText(ascmRfid_New.bindType) + "]类型的RFID标签!"); if (ascmRfid_Old != null) { //存在原绑定 if (ascmRfid_Old.id == ascmRfid_New.id) { //没有改变绑定 ascmRfid_Old = null; } else { //新绑定 ascmRfid_Old.bindId = ""; ascmRfid_Old.status = ""; if (!string.IsNullOrEmpty(ascmRfid_New.status) && ascmRfid_New.status != AscmRfid.StatusDefine.cancel) throw new Exception("RFID标签【" + ascmRfid_New.id + "】已经处于[" + AscmRfid.StatusDefine.DisplayText(ascmRfid_New.status) + "]状态,不能重复绑定!"); if (!string.IsNullOrEmpty(ascmRfid_New.bindId)) throw new Exception("RFID标签【" + ascmRfid_New.id + "】已经绑定[" + ascmRfid_New.bindId + "],不能重复绑定!"); ascmRfid_New.bindId = ascmEmployeeCar.id.ToString(); ascmRfid_New.status = ""; ascmEmployeeCar.rfid = ascmRfid_New.id; } } else { ascmRfid_New.bindId = ascmEmployeeCar.id.ToString(); ascmRfid_New.status = ""; ascmEmployeeCar.rfid = ascmRfid_New.id; } } */ AscmEmployeeCarService.GetInstance().Save(_new, ascmEmployeeCar, ascmRfid_Old, ascmRfid_New_Update, ascmRfid_New_Save); /* using (ITransaction tx = YnDaoHelper.GetInstance().nHibernateHelper.GetCurrentSession().BeginTransaction()) { try { if (!id.HasValue) { YnDaoHelper.GetInstance().nHibernateHelper.Save(ascmEmployeeCar); } else { YnDaoHelper.GetInstance().nHibernateHelper.Update(ascmEmployeeCar); } if (ascmRfid_Old!=null) YnDaoHelper.GetInstance().nHibernateHelper.Update(ascmRfid_Old); if (ascmRfid_New != null) YnDaoHelper.GetInstance().nHibernateHelper.Update(ascmRfid_New); tx.Commit();//正确执行提交 } catch (Exception ex) { tx.Rollback();//回滚 throw ex; } }*/ jsonObjectResult.result = true; jsonObjectResult.message = ""; jsonObjectResult.id = ascmEmployeeCar.id.ToString(); jsonObjectResult.entity = ascmEmployeeCar; } catch (Exception ex) { jsonObjectResult.message = ex.Message; } string sReturn = JsonConvert.SerializeObject(jsonObjectResult); return Content(sReturn); }
public ContentResult ChoiceMaterialSubCategorySave(string releaseHeaderIds, string zmtlCategoryStatus, string dmtlCategoryStatus, string wmtlCategoryStatus) { JsonObjectResult jsonObjectResult = new JsonObjectResult(); List<AscmMaterialSubCategory> list = null; try { string userName = string.Empty; if (User.Identity.IsAuthenticated) { userName = User.Identity.Name; } string whereOther = AscmCommonHelperService.GetInstance().IsJudgeListCount(releaseHeaderIds, "id"); list = AscmMaterialSubCategoryService.GetInstance().GetList(null, "", "", "", whereOther); if (list != null && list.Count > 0) { foreach (AscmMaterialSubCategory ascmMaterialSubCategory in list) { if (zmtlCategoryStatus != "kz" && !string.IsNullOrEmpty(zmtlCategoryStatus)) { ascmMaterialSubCategory.zMtlCategoryStatus = zmtlCategoryStatus; } else if (zmtlCategoryStatus == "kz") { ascmMaterialSubCategory.zMtlCategoryStatus = ""; } if (dmtlCategoryStatus != "kz" && !string.IsNullOrEmpty(dmtlCategoryStatus)) { ascmMaterialSubCategory.dMtlCategoryStatus = dmtlCategoryStatus; } else if (dmtlCategoryStatus == "kz") { ascmMaterialSubCategory.dMtlCategoryStatus = ""; } if (wmtlCategoryStatus != "kz" && !string.IsNullOrEmpty(wmtlCategoryStatus)) { ascmMaterialSubCategory.wMtlCategoryStatus = wmtlCategoryStatus; } else if (wmtlCategoryStatus == "kz") { ascmMaterialSubCategory.wMtlCategoryStatus = ""; } ascmMaterialSubCategory.modifyUser = userName; ascmMaterialSubCategory.modifyTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm"); } AscmMaterialSubCategoryService.GetInstance().Update(list); } jsonObjectResult.result = true; } catch (Exception ex) { jsonObjectResult.result = false; jsonObjectResult.message = ex.Message; } string sReturn = JsonConvert.SerializeObject(jsonObjectResult); return Content(sReturn); }
public ContentResult CloseGetMaterialTask(string releaseHeaderIds) { JsonObjectResult jsonObjectResult = new JsonObjectResult(); List<AscmGetMaterialTask> list = null; string userName = string.Empty; if (User.Identity.IsAuthenticated) { userName = User.Identity.Name; } try { string whereOther = "", whereQueryWord = ""; if (!string.IsNullOrEmpty(releaseHeaderIds)) { whereQueryWord = "id in (" + releaseHeaderIds + ")"; whereOther = YnBaseClass2.Helper.StringHelper.SqlWhereAndAdd(whereOther, whereQueryWord); } whereQueryWord = "status != '" + AscmGetMaterialTask.StatusDefine.finish + "'"; whereOther = YnBaseClass2.Helper.StringHelper.SqlWhereAndAdd(whereOther, whereQueryWord); List<AscmGetMaterialTask> listAscmGetMaterialTask = AscmGetMaterialTaskService.GetInstance().GetList(null, "", "", "", whereOther); if (listAscmGetMaterialTask != null && listAscmGetMaterialTask.Count > 0) { foreach (AscmGetMaterialTask ascmGetMaterialTask in listAscmGetMaterialTask) { ascmGetMaterialTask.status = AscmGetMaterialTask.StatusDefine.close; ascmGetMaterialTask.modifyUser = userName; ascmGetMaterialTask.modifyTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm"); if (list == null) list = new List<AscmGetMaterialTask>(); list.Add(ascmGetMaterialTask); } } if (list == null || list.Count == 0) throw new Exception("找不到更新的任务!"); if (list != null && list.Count > 0) { AscmGetMaterialTaskService.GetInstance().Save(list); } jsonObjectResult.result = true; jsonObjectResult.message = ""; } catch (Exception ex) { jsonObjectResult.result = true; jsonObjectResult.message = ex.Message; } string sReturn = JsonConvert.SerializeObject(jsonObjectResult); return Content(sReturn); }
public ContentResult ParameterSave(ParameterModel parameterModel, int? id) { JsonObjectResult jsonObjectResult = new JsonObjectResult(); try { //公共 YnParameterService.GetInstance().SetValue(MyParameter.doorLedTitle, parameterModel.doorLedTitle.Trim()); YnParameterService.GetInstance().SetValue(MyParameter.reserveInvalid, parameterModel.reserveInvalid.ToString()); decimal supplierPassDuration = (decimal)0.5; supplierPassDuration = (int)(parameterModel.supplierPassDuration / (decimal)0.5) * (decimal)0.5; if (supplierPassDuration > 24) supplierPassDuration = 24; if (supplierPassDuration < 0) supplierPassDuration = 0; YnParameterService.GetInstance().SetValue(MyParameter.supplierPassDuration, supplierPassDuration.ToString("0.0")); string employeeCarExemptionLevel_old = YnParameterService.GetInstance().GetValue(MyParameter.employeeCarExemptionLevel); YnParameterService.GetInstance().SetValue(MyParameter.employeeCarExemptionLevel, parameterModel.employeeCarExemptionLevel.Trim()); //设置员工车辆免检 if (employeeCarExemptionLevel_old.Trim() != parameterModel.employeeCarExemptionLevel.Trim()) { AscmEmployeeCarService.GetInstance().SetExemption(parameterModel.employeeCarExemptionLevel.Trim()); } jsonObjectResult.result = true; jsonObjectResult.message = ""; } catch (Exception ex) { jsonObjectResult.message = ex.Message; } string result = JsonConvert.SerializeObject(jsonObjectResult); return Content(result); }
public ActionResult LoadJob(string jobName) { JsonObjectResult jsonObjectResult = new JsonObjectResult(); try { if (jobName == null || jobName.Trim() == "") throw new Exception("请选择作业!"); AscmJob ascmJob = AscmJobService.GetInstance().Get(jobName.Trim()); jsonObjectResult.result = true; jsonObjectResult.id = jobName.Trim(); jsonObjectResult.entity = ascmJob; } catch (Exception ex) { jsonObjectResult.message = ex.Message; } return Json(jsonObjectResult, JsonRequestBehavior.AllowGet); }
public ContentResult ReadingHeadSave(AscmReadingHead ascmReadingHead_Model, int? id) { JsonObjectResult jsonObjectResult = new JsonObjectResult(); try { AscmReadingHead ascmReadingHead = null; if (id.HasValue) { ascmReadingHead = AscmReadingHeadService.GetInstance().Get(id.Value); } else { ascmReadingHead = new AscmReadingHead(); } if (ascmReadingHead == null) throw new Exception("保存RFID读头信息失败!"); //if (string.IsNullOrEmpty(ascmReadingHead_Model.bindType)) // throw new Exception("必须选择RFID类型!"); if (string.IsNullOrEmpty(ascmReadingHead_Model.ip)) throw new Exception("必须输入ip地址!"); //if (ascmReadingHead_Model.plateNumber == null || ascmReadingHead_Model.plateNumber.Trim() == "") // throw new Exception("员工车辆车牌号不能为空!"); ascmReadingHead.bindType = ascmReadingHead_Model.bindType; ascmReadingHead.bindId = ""; ascmReadingHead.ip = ascmReadingHead_Model.ip.Trim(); ascmReadingHead.port = ascmReadingHead_Model.port; ascmReadingHead.status = ""; if (ascmReadingHead_Model.address != null && ascmReadingHead_Model.address != "") ascmReadingHead.address = ascmReadingHead_Model.address.Trim(); if (!id.HasValue) { object object1 = YnDaoHelper.GetInstance().nHibernateHelper.GetObject("select count(*) from AscmReadingHead where ip='" + ascmReadingHead_Model.ip.Trim() + "'"); if (object1 == null) throw new Exception("查询异常!"); int iCount = 0; if (int.TryParse(object1.ToString(), out iCount) && iCount > 0) throw new Exception("已经存在此ip【" + ascmReadingHead_Model.ip.Trim() + "】!"); int maxId = YnDaoHelper.GetInstance().nHibernateHelper.GetMaxId("select max(id) from AscmReadingHead"); ascmReadingHead.id = maxId + 1; } else { object object1 = YnDaoHelper.GetInstance().nHibernateHelper.GetObject("select count(*) from AscmReadingHead where ip='" + ascmReadingHead_Model.ip.Trim() + "' and id<>" + id.Value + ""); if (object1 == null) throw new Exception("查询异常!"); int iCount = 0; if (int.TryParse(object1.ToString(), out iCount) && iCount > 0) throw new Exception("已经存在此ip【" + ascmReadingHead_Model.ip.Trim() + "】!"); //AscmEmployeeCarService.GetInstance().Update(ascmEmployeeCar); } using (ITransaction tx = YnDaoHelper.GetInstance().nHibernateHelper.GetCurrentSession().BeginTransaction()) { try { if (!id.HasValue) { YnDaoHelper.GetInstance().nHibernateHelper.Save(ascmReadingHead); } else { YnDaoHelper.GetInstance().nHibernateHelper.Update(ascmReadingHead); } tx.Commit();//正确执行提交 } catch (Exception ex) { tx.Rollback();//回滚 throw ex; } } jsonObjectResult.result = true; jsonObjectResult.message = ""; jsonObjectResult.id = ascmReadingHead.id.ToString(); jsonObjectResult.entity = ascmReadingHead; } catch (Exception ex) { jsonObjectResult.message = ex.Message; } string sReturn = JsonConvert.SerializeObject(jsonObjectResult); return Content(sReturn); }
public ContentResult DeliveryNotifyMainSave(AscmDeliveryNotifyMain ascmDeliveryNotifyMain_Model, int? id) { JsonObjectResult jsonObjectResult = new JsonObjectResult(); try { AscmDeliveryNotifyMain ascmDeliveryNotifyMain = null; if (id.HasValue) { ascmDeliveryNotifyMain = AscmDeliveryNotifyMainService.GetInstance().Get(id.Value); } YnFrame.Dal.Entities.YnUser ynUser = YnFrame.Web.FormsAuthenticationService.GetInstance().GetTicketUserData(); if (ynUser == null) throw new Exception("用户错误!"); AscmUserInfo ascmUserInfo = AscmUserInfoService.GetInstance().Get(ynUser.userId); if (ascmUserInfo.extExpandType == "erp" && ascmUserInfo.employeeId > 0) { ascmUserInfo.ascmEmployee = AscmEmployeeService.GetInstance().Get(ascmUserInfo.employeeId); } else { throw new Exception("当前用户不能提交修改!"); } if (ascmDeliveryNotifyMain == null) throw new Exception("保存预约信息失败!"); ascmDeliveryNotifyMain.ascmMaterialItem = AscmMaterialItemService.GetInstance().Get(ascmDeliveryNotifyMain.materialId); if (ascmDeliveryNotifyMain.ascmMaterialItem==null) throw new Exception("送货通知没有关联物料!"); if (ascmDeliveryNotifyMain.ascmMaterialItem.buyerId != ascmUserInfo.employeeId) throw new Exception("不能修改其他采购员的送货通知!"); //if (ascmDeliveryNotifyMain_Model.name == null || ascmDeliveryNotifyMain_Model.name.Trim() == "") //throw new Exception("....不能为空!"); if(ascmDeliveryNotifyMain.status!=AscmDeliveryNotifyMain.StatusDefine.confirm) throw new Exception("送货通知已经【" + ascmDeliveryNotifyMain.statusCn + "】!"); DateTime appointmentStartTime = DateTime.Now; if (DateTime.TryParse(ascmDeliveryNotifyMain_Model.appointmentStartTime, out appointmentStartTime)) { ascmDeliveryNotifyMain.appointmentStartTime = appointmentStartTime.ToString("yyyy-MM-dd HH:mm"); } else { throw new Exception("预约开始送货时间格式错误!"); } DateTime appointmentEndTime = DateTime.Now; if (DateTime.TryParse(ascmDeliveryNotifyMain_Model.appointmentEndTime, out appointmentEndTime)) { ascmDeliveryNotifyMain.appointmentEndTime = appointmentEndTime.ToString("yyyy-MM-dd HH:mm"); } else { throw new Exception("预约截止送货时间格式错误!"); } System.TimeSpan ts = DateTime.Now.Subtract(appointmentStartTime); if (ts.Minutes >= 0) throw new Exception("预约开始时间应在现在时间之后!"); ts = appointmentEndTime.Subtract(appointmentStartTime); if(ts.Minutes<=0) throw new Exception("预约开始时间应在截止时间之前!"); //ascmDeliveryNotifyMain.sex = ascmDeliveryNotifyMain_Model.sex.Trim(); AscmDeliveryNotifyMainService.GetInstance().Update(ascmDeliveryNotifyMain); jsonObjectResult.result = true; jsonObjectResult.message = ""; jsonObjectResult.id = ascmDeliveryNotifyMain.id.ToString(); jsonObjectResult.entity = ascmDeliveryNotifyMain; } catch (Exception ex) { jsonObjectResult.message = ex.Message; } string sReturn = JsonConvert.SerializeObject(jsonObjectResult); return Content(sReturn); }
public ContentResult MarkTask(int? id, int? wipEntityId) { JsonObjectResult jsonObjectResult = new JsonObjectResult(); string userName = string.Empty; if (User.Identity.IsAuthenticated) { userName = User.Identity.Name; } try { bool isContainWarehouse = false; string warehouse = string.Empty; AscmGetMaterialTask ascmGetMaterialTask = null; if (id.HasValue) { ascmGetMaterialTask = AscmGetMaterialTaskService.GetInstance().Get(id.Value); if (ascmGetMaterialTask == null) throw new Exception("该任务不存在!"); warehouse = string.IsNullOrEmpty(ascmGetMaterialTask.warehouserId) ? null : ascmGetMaterialTask.warehouserId.Substring(0, 4).ToUpper().ToString(); } string whereOther = "", whereQueryWord = ""; whereQueryWord = "ruleType = '" + AscmGenerateTaskRule.RuleTypeDefine.typeofWarehouse + "'"; whereOther = YnBaseClass2.Helper.StringHelper.SqlWhereAndAdd(whereOther, whereQueryWord); whereQueryWord = "identificationId = " + ascmGetMaterialTask.IdentificationId; whereOther = YnBaseClass2.Helper.StringHelper.SqlWhereAndAdd(whereOther, whereQueryWord); List<AscmGenerateTaskRule> list = AscmGenerateTaskRuleService.GetInstance().GetList(null, "", "", "", whereOther); if (list != null && list.Count > 0) { foreach (AscmGenerateTaskRule ascmGenerateTaskRule in list) { if (!string.IsNullOrEmpty(ascmGenerateTaskRule.relatedRanker) && ascmGenerateTaskRule.relatedRanker == ascmGetMaterialTask.rankerId) { if (!string.IsNullOrEmpty(ascmGenerateTaskRule.ruleCode)) { string[] myArray = ascmGenerateTaskRule.ruleCode.Split('&'); string warehouseString = myArray[0].Substring(myArray[0].IndexOf("(") + 1, myArray[0].IndexOf(")") - myArray[0].IndexOf("(") - 1); if (!string.IsNullOrEmpty(warehouse) && warehouseString.IndexOf(warehouse) > -1) { isContainWarehouse = true; break; } } } else if (string.IsNullOrEmpty(ascmGenerateTaskRule.relatedRanker)) { if (!string.IsNullOrEmpty(ascmGenerateTaskRule.ruleCode)) { string[] myArray = ascmGenerateTaskRule.ruleCode.Split('&'); string warehouseString = myArray[0].Substring(myArray[0].IndexOf("(") + 1, myArray[0].IndexOf(")") - myArray[0].IndexOf("(") - 1); if (!string.IsNullOrEmpty(warehouse) && warehouseString.IndexOf(warehouse) > -1) { isContainWarehouse = true; break; } } } } } if (!isContainWarehouse) throw new Exception("该子库无法标记!"); if (isContainWarehouse) { AscmMarkTaskLog ascmMarkTaskLog = null; if (!(id.HasValue && wipEntityId.HasValue)) throw new Exception("请选择须标记的作业!"); if (id.HasValue && wipEntityId.HasValue) { object object1 = YnDaoHelper.GetInstance().nHibernateHelper.GetObject("select count(*) from AscmMarkTaskLog where wipEntityId = " + wipEntityId.ToString() + " and taskId = " + id.ToString() + " and isMark = 1"); if (object1 == null) throw new Exception("查询异常!"); int iCount = 0; if (int.TryParse(object1.ToString(), out iCount) && iCount > 0) throw new Exception("该作业已标记!"); int maxId = YnDaoHelper.GetInstance().nHibernateHelper.GetMaxId("select max(id) from AscmMarkTaskLog"); ascmMarkTaskLog = new AscmMarkTaskLog(); ascmMarkTaskLog.id = ++maxId; ascmMarkTaskLog.createUser = userName; ascmMarkTaskLog.createTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm"); ascmMarkTaskLog.modifyUser = userName; ascmMarkTaskLog.modifyTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm"); ascmMarkTaskLog.wipEntityId = wipEntityId.Value; ascmMarkTaskLog.taskId = id.Value; ascmMarkTaskLog.isMark = 1; ascmMarkTaskLog.markType = "NONAUTO"; ascmMarkTaskLog.warehouseId = warehouse; if (!string.IsNullOrEmpty(ascmGetMaterialTask.relatedMark)) ascmGetMaterialTask.relatedMark += ","; ascmGetMaterialTask.relatedMark += ascmMarkTaskLog.id.ToString(); ascmGetMaterialTask.modifyUser = userName; ascmGetMaterialTask.modifyTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm"); //执行事务 ISession session = YnDaoHelper.GetInstance().nHibernateHelper.GetCurrentSession(); session.Clear(); using (ITransaction tx = session.BeginTransaction()) { try { //更改任务标记 if (ascmGetMaterialTask != null) AscmGetMaterialTaskService.GetInstance().Update(ascmGetMaterialTask); //保存标记 if (ascmMarkTaskLog != null) AscmMarkTaskLogService.GetInstance().Save(ascmMarkTaskLog); } catch (Exception ex) { tx.Rollback(); YnBaseClass2.Helper.LogHelper.GetLog().Error("标记失败(Mark AscmMarkTaskLog)", ex); } } jsonObjectResult.result = true; jsonObjectResult.message = ""; } } } catch (Exception ex) { jsonObjectResult.result = false; jsonObjectResult.message = ex.Message; } string sReturn = JsonConvert.SerializeObject(jsonObjectResult); return Content(sReturn); }