public bool Check2(string F_Id) { bool a = false; SearchCondition condition = new SearchCondition(); condition.AddCondition("F_HId", F_Id, SqlOperator.Equal); List <PI_BodyInfo> list = PI_Body.Instance.Find(condition.BuildConditionSql().Replace("Where (1=1) AND ", string.Empty)); foreach (var item in list) { SearchCondition condition2 = new SearchCondition(); condition2.AddCondition("F_OrderDetailedId", item.F_Id, SqlOperator.Equal); List <PI_BodyInfo> list2 = PI_Body.Instance.Find(condition2.BuildConditionSql().Replace("Where (1=1) AND ", string.Empty)); if (list2[0].F_EnCode == "") { return(true); } } return(a); }
public void Status(string F_Id, string userName) { using (DbTransactionScope <PI_HeadInfo> dbtran = base.CreateTransactionScope()) { try { //更新登记单主表审核状态,审核人,审核时间 PI_HeadInfo head = PI_Head.Instance.FindByID(F_Id, dbtran.Transaction); head.F_Status = 1; head.F_Verify = userName; head.F_VeriDate = DateTime.Now; PI_Head.Instance.Update(head, F_Id, dbtran.Transaction); //找到登记单子表 SearchCondition condition = new SearchCondition(); condition.AddCondition("F_HId", F_Id, SqlOperator.Equal); List <PI_BodyInfo> list = PI_Body.Instance.Find(condition.BuildConditionSql().Replace("Where (1=1) AND ", string.Empty), dbtran.Transaction); //资产编号 foreach (PI_BodyInfo item in list) { for (int i = 0; i < item.F_InStockNum; i++) { PI_BodyInfo entity = new PI_BodyInfo(); entity.F_Id = Guid.NewGuid().ToString(); entity.F_EnCode = item.F_EnCode; entity.F_FullName = item.F_FullName; entity.F_OrderNo = item.F_OrderNo; entity.F_Supplier = item.F_Supplier; entity.F_Unit = item.F_Unit; entity.F_Description = item.F_Description; PI_Body.Instance.Insert(entity, dbtran.Transaction); } } dbtran.Commit(); } catch (Exception ex) { dbtran.RollBack(); throw ex; } } }
//保存业务类型设置 public void Save(Sys_VouchTypeInfo info, List <Sys_VouchTypeDefaultInfo> dInfo, string keyValue) { using (DbTransactionScope <Sys_VouchTypeInfo> dbtran = base.CreateTransactionScope()) { try { //主子表同时更新 //主表更新/新增 //子表根据主表id全删除 //添加子表 //增加子表 //如果是修改,先删除后增加 SearchCondition condition = new SearchCondition(); condition.AddCondition("F_VouchId", info.F_Id, SqlOperator.Equal); BLLFactory <Sys_VouchTypeDefault> .Instance.DeleteByCondition(condition.BuildConditionSql().Replace("Where (1=1) AND ", string.Empty)); foreach (Sys_VouchTypeDefaultInfo model in dInfo) { //如果不选择默认值,即传入的F_EnCode为null就不插值 if (!string.IsNullOrEmpty(model.F_EnCode)) { Sys_VouchTypeDefault.Instance.Insert(model, dbtran.Transaction); } } //增加主表 this.InsertUpdate(info, keyValue, dbtran.Transaction); dbtran.Commit(); } catch (Exception ex) { dbtran.RollBack(); throw ex; } } }
/// <summary> /// 获得指定间隔时间内未联系的客户列表 /// </summary> /// <param name="unContactDays">和最后联系日期的间隔天数</param> /// <param name="userId">当前用户</param> /// <returns></returns> public List <CustomerInfo> GetUnContactList(int unContactDays, string userId) { List <CustomerInfo> listAll = new List <CustomerInfo>(); //根据用户配置的信息进行逐条处理,然后合并记录 List <CustomerAlarmInfo> alarmList = BLLFactory <CustomerAlarm> .Instance.FindByUser(userId); foreach (CustomerAlarmInfo alarmInfo in alarmList) { //如果存在高级查询对象信息,则使用高级查询条件,否则使用主表条件查询 SearchCondition condition = new SearchCondition(); DateTime today = Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd")); int FollowExpireDays = alarmInfo.Days; if (FollowExpireDays < 1) { FollowExpireDays = 1; } condition.AddCondition("Grade", alarmInfo.Grade, SqlOperator.Equal); condition.AddCondition("LastContactDate", today.AddDays(-1 * FollowExpireDays), SqlOperator.LessThanOrEqual); condition.AddCondition("Deleted", 0, SqlOperator.Equal); //不显示删除的 condition.AddCondition("Creator", userId, SqlOperator.Equal); //仅仅选择该用户的记录 string where = condition.BuildConditionSql().Replace("Where", ""); List <CustomerInfo> list = baseDal.Find(where); foreach (CustomerInfo info in list) { bool readed = BLLFactory <InformationStatus> .Instance.IsReadedStatus(userId, InformationCategory.客户联系, info.ID); info.Data1 = readed ? "已读" : "未读"; } listAll.AddRange(list); } return(listAll); }
/// <summary> /// 根据查询条件构造查询语句 /// </summary> private string GetConditionSql() { SearchCondition condition = new SearchCondition(); condition.AddCondition("Name", this.txtName.Text, SqlOperator.Like); condition.AddCondition("AuthGid", this.txtFunctionId.Text, SqlOperator.Like); condition.AddCondition("WinformClass", this.txtWinformType.Text, SqlOperator.Like); condition.AddCondition("Url", this.txtUrl.Text, SqlOperator.Like); if (this.txtVisible.Checked) { condition.AddCondition("IsVisable", 1, SqlOperator.Equal); } else { condition.AddCondition("IsVisable", 2, SqlOperator.Equal); } string where = condition.BuildConditionSql().Replace("Where", ""); //如果是单击节点得到的条件,则使用树列表的,否则使用查询条件的 if (!string.IsNullOrEmpty(treeConditionSql)) { where = treeConditionSql; } return(where); }
/// <summary> /// 根据查询条件构造查询语句 /// </summary> private string GetConditionSql() { SearchCondition condition = new SearchCondition(); condition.AddCondition("ID", this.txtID.Text, SqlOperator.Like); if ((this.txtCategory.SelectedItem as CListItem) != null) { condition.AddCondition("CouponCategory_ID", (this.txtCategory.SelectedItem as CListItem).Value, SqlOperator.Equal); } condition.AddCondition("MobilePhone", this.txtMobilePhone.Text, SqlOperator.Like); condition.AddCondition("FullName", this.txtFullName.Text, SqlOperator.Like); if (this.txtEnabled.SelectedIndex != -1) { condition.AddCondition("DELETED", this.txtEnabled.SelectedIndex, SqlOperator.Equal); } string where = condition.BuildConditionSql().Replace("Where", ""); //如果是单击节点得到的条件,则使用树列表的,否则使用查询条件的 if (!string.IsNullOrEmpty(treeConditionSql)) { where = treeConditionSql; } return(where); }
public string VerifyReturnGoods(string Id, string user) { using (DbTransactionScope <SO_ReturnedStockHeadInfo> dbtran = base.CreateTransactionScope()) { try { DateTime time = DateTime.Now; //查询到退货子表单据 SO_ReturnedStockHeadInfo HeadInfo = BLLFactory <SO_ReturnedStockHead> .Instance.FindByID(Id); SearchCondition search = new SearchCondition(); search.AddCondition("F_Hid", Id, SqlOperator.Equal); List <SO_ReturnedStockBodyInfo> ReBodyinfo = BLLFactory <SO_ReturnedStockBody> .Instance.Find(search.BuildConditionSql().Replace("Where (1=1) AND ", string.Empty).Replace("Where (1=1)", " ( 1 = 1 ) ")); //查询出所有产品的库存 List <Sys_StockInfo> StockList = BLLFactory <Sys_Stock> .Instance.GetAll(); //添加库存记录 List <Sys_StockHistoryInfo> HisList = new List <Sys_StockHistoryInfo>(); //添加出库记录 List <Sys_OutReturnInfo> list = new List <Sys_OutReturnInfo>(); //更新 产品库存 foreach (SO_ReturnedStockBodyInfo item in ReBodyinfo) { Sys_StockInfo StockInfo = StockList.Find(u => u.F_WarehouseId == item.F_WarehouseId && u.F_CargoPositionId == item.F_CargoPositionId && u.F_GoodsId == item.F_GoodsId); Hashtable hash = new Hashtable(); hash.Add("F_Number", StockInfo.F_Number + item.F_ReturnNum); Sys_Stock.Instance.Update(StockInfo.F_Id, hash, dbtran.Transaction); Sys_OutReturnInfo outRec = new Sys_OutReturnInfo(); outRec.F_Id = Guid.NewGuid().ToString(); outRec.F_EnCode = HeadInfo.F_EnCode; outRec.F_Batch = item.F_EnCode; outRec.F_Vendor = HeadInfo.F_CustomerId; outRec.F_VendorName = HeadInfo.F_CustomerName; outRec.F_Verify = user; outRec.F_Maker = HeadInfo.F_Operator; outRec.F_Contacts = HeadInfo.F_Contacts; outRec.F_TelePhone = HeadInfo.F_TelePhone; outRec.F_Address = HeadInfo.F_Address; outRec.F_VeriDate = time; outRec.F_WarehouseId = item.F_WarehouseId; outRec.F_WarehouseName = item.F_WarehouseName; outRec.F_GoodsName = item.F_GoodsName; outRec.F_GoodsId = item.F_GoodsId; outRec.F_CargoPositionId = item.F_CargoPositionId; outRec.F_CargoPositionName = item.F_CargoPositionName; outRec.F_SpecifModel = item.F_SpecifModel; outRec.F_SellingPrice = item.F_SellingPrice.ToString(); outRec.F_PurchasePrice = item.F_PurchasePrice.ToString(); outRec.F_Unit = item.F_Unit; outRec.F_OutStockNum = item.F_OutStockNum; outRec.F_ReturnNum = item.F_ReturnNum; outRec.F_CreatorTime = time; list.Add(outRec); //产品库存变更信息 Sys_StockHistoryInfo HistoryInfo = new Sys_StockHistoryInfo(); HistoryInfo.F_CargoPositionId = item.F_CargoPositionId; HistoryInfo.F_CargoPositionName = item.F_CargoPositionName; HistoryInfo.F_GoodsName = item.F_GoodsName; HistoryInfo.F_Batch = item.F_Batch; HistoryInfo.F_WarehouseId = item.F_WarehouseId; HistoryInfo.F_WarehouseName = item.F_WarehouseName; HistoryInfo.F_BllCategory = "出库退回"; HistoryInfo.F_OperationNum = item.F_ReturnNum; HistoryInfo.F_VendorName = HeadInfo.F_CustomerName; HistoryInfo.F_Contacts = HeadInfo.F_Contacts; HistoryInfo.F_TelePhone = HeadInfo.F_TelePhone; HistoryInfo.F_Address = HeadInfo.F_Address; HistoryInfo.F_Maker = HeadInfo.F_Operator; HistoryInfo.F_Verify = HeadInfo.F_AuditingUser; HistoryInfo.F_VeriDate = time; HistoryInfo.F_Unit = item.F_Unit; HistoryInfo.F_CreatorTime = time; HistoryInfo.F_Description = HeadInfo.F_Description; HistoryInfo.F_EnCode = HeadInfo.F_EnCode; HisList.Add(HistoryInfo); } Sys_OutReturn.Instance.InsertRange(list, dbtran.Transaction); Sys_StockHistory.Instance.InsertRange(HisList, dbtran.Transaction); //更该审核标识 Hashtable has = new Hashtable(); has.Add("F_AuditingUser", user); has.Add("F_VeriDate", time); has.Add("F_Status", 1); SO_ReturnedStockHead.Instance.Update(Id, has, dbtran.Transaction); dbtran.Commit(); return("操作成功"); } catch (Exception) { dbtran.RollBack(); return("操作失败"); } } }
/// <summary> /// 获取表体 /// </summary> /// <param name="keyValue"></param> /// <returns></returns> public ActionResult GetFormJson1(string keyValue) { SearchCondition condition = new SearchCondition(); condition.AddCondition("F_HId", keyValue, SqlOperator.Equal); List <Allocation_BodyInfo> list = BLLFactory <Allocation_Body> .Instance.Find(condition.BuildConditionSql().Replace("Where (1=1) AND ", string.Empty)); return(Content(JsonAppHelper.ToJson(list))); }
/// <summary> ///审核单据 /// </summary> /// <param name="Id">审核单据</param> /// <param name="user">审核人</param> public string Audit(string Id, string user) { using (DbTransactionScope <SO_HeadInfo> dbtran = base.CreateTransactionScope()) { DateTime time = DateTime.Now; try { SearchCondition condition = new SearchCondition(); condition.AddCondition("F_Id", Id, SqlOperator.Equal); SO_HeadInfo head = SO_Head.Instance.FindSingle(condition.BuildConditionSql().Replace("Where (1=1) AND ", string.Empty), dbtran.Transaction); if (head.F_Status == 1) { return("单据已被审核"); } else { Hashtable hash = new Hashtable(); hash.Add("F_Status", 1); hash.Add("F_AuditingUser", user); hash.Add("F_VeriDate", time); SO_Head.Instance.Update(Id, hash, dbtran.Transaction); dbtran.Commit(); return("单据审核成功"); #region 审核后直接出库 // SO_HeadInfo info = BLLFactory<SO_Head>.Instance.FindByID(Id); // if (info.F_Status == "True") return "单据已审核出库"; // //根据单据找到需要出库的产品 // SearchCondition search = new SearchCondition(); // search.AddCondition("F_Hid", Id, SqlOperator.Equal); // List<SO_BodyInfo> BodyInfo = BLLFactory<SO_Body>.Instance.Find(search.BuildConditionSql().Replace("Where (1=1) AND ", string.Empty).Replace("Where (1=1)", " ( 1 = 1 ) ")); ////获取单据 // SO_HeadInfo HeadInfo = BLLFactory<SO_Head>.Instance.FindByID(Id); // //循环出库,添加记录 // List<Sys_StockInfo> list = BLLFactory<Sys_Stock>.Instance.GetAll(); // List<Sys_OutRecordsInfo> OutList = new List<Sys_OutRecordsInfo>(); // List<Sys_StockHistoryInfo> StockHisList = new List<Sys_StockHistoryInfo>(); // //客户Id // string CustomerId = BLLFactory<SO_Head>.Instance.FindByID(Id).F_CustomerId; // foreach (var item in BodyInfo) // { // Sys_StockInfo stockInfo = list.Find(u => u.F_CargoPositionId == item.F_CargoPositionId && u.F_WarehouseId == item.F_WarehouseId && u.F_GoodsId == item.F_GoodsId); // if (stockInfo.F_Number - item.F_OutStockNum < 0) // { // return "产品数量发生了变化,请重新选择审核出库"; // } // Hashtable has = new Hashtable(); // has.Add("F_Number", stockInfo.F_Number - item.F_OutStockNum); // Sys_Stock.Instance.Update(stockInfo.F_Id, has, dbtran.Transaction); // //产品出库记录 // Sys_OutRecordsInfo outInfo = new Sys_OutRecordsInfo(); // outInfo.F_Batch = info.F_EnCode; // outInfo.F_GoodsId = item.F_GoodsId; // outInfo.F_GoodsName = item.F_GoodsName; // outInfo.F_EnCode = item.F_EnCode; // outInfo.F_OutStockNum =item.F_OutStockNum; // outInfo.F_CargoPositionId = item.F_CargoPositionId; // outInfo.F_CargoPositionName = item.F_CargoPositionName; // outInfo.F_WarehouseId = item.F_WarehouseId; // outInfo.F_WarehouseName = item.F_WarehouseName; // outInfo.F_CreatorTime = DateTime.Now; // outInfo.F_CreatorUserId = item.F_CreatorUserId; // outInfo.F_Description = item.F_Description; // outInfo.F_CustomerId = CustomerId; // outInfo.F_Unit = item.F_Unit; // outInfo.F_Address = info.F_Address; // outInfo.F_Contacts = info.F_Contacts; // outInfo.F_Operator = info.F_Operator; // outInfo.F_CustomerName = info.F_CustomerName; // outInfo.F_TelePhone = info.F_TelePhone; // OutList.Add(outInfo); // //添加库存信息 // Sys_StockHistoryInfo HistoryInfo = new Sys_StockHistoryInfo(); // HistoryInfo.F_CargoPositionId = item.F_CargoPositionId; // HistoryInfo.F_CargoPositionName = item.F_CargoPositionName; // HistoryInfo.F_WarehouseId = item.F_WarehouseId; // HistoryInfo.F_WarehouseName = item.F_WarehouseName; // HistoryInfo.F_EnCode= info.F_EnCode; // HistoryInfo.F_Batch =item.F_Batch; // HistoryInfo.F_BllCategory = "出库"; // HistoryInfo.F_OperationNum = 0 - item.F_OutStockNum; // HistoryInfo.F_SpecifModel = item.F_SpecifModel; // HistoryInfo.F_Vendor = user; // HistoryInfo.F_GoodsId = item.F_GoodsId; // HistoryInfo.F_GoodsName = item.F_GoodsName; // HistoryInfo.F_Unit = item.F_Unit; // HistoryInfo.F_VendorName = info.F_CustomerName; // HistoryInfo.F_Contacts = info.F_Contacts; // HistoryInfo.F_TelePhone = info.F_TelePhone; // HistoryInfo.F_Maker = info.F_CreatorUserId; // HistoryInfo.F_Verify = user; // HistoryInfo.F_VeriDate = time; // StockHisList.Add(HistoryInfo); // } // //添加出库记录 // Sys_OutRecords.Instance.InsertRange(OutList, dbtran.Transaction); // //添加库存记录 // Sys_StockHistory.Instance.InsertRange(StockHisList, dbtran.Transaction); // //审核单据 // Hashtable hash = new Hashtable(); // hash.Add("F_Status", 1); // hash.Add("F_AuditingUser", user); // hash.Add("F_VeriDate", time); // SO_Head.Instance.Update(Id, hash, dbtran.Transaction); // dbtran.Commit(); // return "审核出库成功"; #endregion } } catch (Exception ex) { dbtran.RollBack(); return("操作失败"); throw ex; } } }
private string GetConditionStr(SearchCondition condition) { return(condition.BuildConditionSql().Replace("Where (1=1) AND ", string.Empty).Replace("Where (1=1)", " ( 1 = 1 ) ")); }
/// <summary> /// 获取分页操作的查询条件 /// </summary> /// <returns></returns> protected virtual string GetPagerCondition() { string where = ""; //增加一个CustomedCondition条件,根据客户这个条件进行查询 string CustomedCondition = Request["CustomedCondition"] ?? ""; if (!string.IsNullOrWhiteSpace(CustomedCondition)) { where = CustomedCondition;//直接使用条件 } else { #region 根据数据库字段列,对所有可能的参数进行获值,然后构建查询条件 SearchCondition condition = new SearchCondition(); DataTable dt = BLLFactory <FileUpload> .Instance.GetFieldTypeList(); foreach (DataRow dr in dt.Rows) { string columnName = dr["ColumnName"].ToString(); string dataType = dr["DataType"].ToString(); //字段增加WHC_前缀字符,避免传递如URL这样的Request关键字冲突 string columnValue = Request["WHC_" + columnName] ?? ""; //对于数值型,如果是显示声明相等的,一般是外键引用,需要特殊处理 bool hasEqualValue = columnValue.StartsWith("="); if (IsDateTime(dataType)) { //condition.AddDateCondition(columnName, columnValue);20200228 } else if (IsNumericType(dataType)) { //如果数据库是数值类型,而传入的值是true或者false,那么代表数据库的参考值为1,0,需要进行转换 bool boolValue = false; bool isBoolenValue = bool.TryParse(columnValue, out boolValue); if (isBoolenValue) { condition.AddCondition(columnName, boolValue ? 1 : 0, SqlOperator.Equal); } else if (hasEqualValue) { columnValue = columnValue.Substring(columnValue.IndexOf("=") + 1); condition.AddCondition(columnName, columnValue, SqlOperator.Equal); } else { //condition.AddNumberCondition(columnName, columnValue);20200228 } } else { if (ValidateUtil.IsNumeric(columnValue)) { condition.AddCondition(columnName, columnValue, SqlOperator.Equal); } else { condition.AddCondition(columnName, columnValue, SqlOperator.Like); } } } #endregion where = condition.BuildConditionSql().Replace("Where", ""); } return(where); }
/// <summary> /// 登录系统 /// </summary> /// <param name="loginModel">登录对象</param> /// <returns></returns> private async Task <KgmApiResultEntity> loginSystemAsync(LoginSystemModel loginModel) { KgmApiResultEntity result = new KgmApiResultEntity();//返回对象 result.result = false; result.message = ""; string errorInfo = string.Empty; if (!bRegister(out errorInfo)) { result.result = false; result.message = errorInfo; return(result); } Sys_UserInfo loginResult;//登录对象 bool bAdmin = false; if (loginModel.Account.Equals(ConstValue.KGMADMIN_USERNAME) && loginModel.Password.Equals(ConstValue.KGMADMIN_PASSWORD)) { //超级管理员 loginResult = new Sys_UserInfo(); loginResult.F_Id = ConstValue.KGMADMIN_USERID; loginResult.F_UserPassword = ConstValue.KGMADMIN_PASSWORD; loginResult.F_RealName = ConstValue.KGMADMIN_USERNAME; bAdmin = true; } else { SearchCondition condition = new SearchCondition(); condition.AddCondition("F_Account", loginModel.Account, SqlOperator.Equal); loginResult = BLLFactory <Sys_User> .Instance.FindSingle(condition.BuildConditionSql().Replace(" Where (1=1) AND", string.Empty)); } if (loginResult == null) { SaveLoginLog(loginModel.Account, string.Empty, loginModel.LoginSystem.ToString(), false, "用户名不存在!"); result.result = false; result.message = "用户名不存在!"; } else if (!loginResult.F_UserPassword.Equals(DESEncrypt.Encrypt(loginModel.Password))) { SaveLoginLog(loginModel.Account, string.Empty, loginModel.LoginSystem.ToString(), false, "用户名与密码不匹配!"); result.result = false; result.message = "用户名与密码不匹配!"; } else { string token = ""; //token //生成token token = await JWTTokenHelper.GetTokenAsync(loginResult.F_Id, loginModel.LoginSystem, bAdmin); SaveLoginLog(loginResult.F_Account, loginResult.F_NickName, loginModel.LoginSystem.ToString(), true, "登录成功"); result.result = true; result.message = token; } return(result); }
/// <summary> /// 产品入库操作 /// </summary> /// <param name="Batch"></param> /// <param name="stockinfo"></param> /// <returns></returns> public string InStock(string Batch, List <PI_BodyInfo> stockinfo) { using (DbTransactionScope <PI_BodyInfo> dbtran = base.CreateTransactionScope()) { try { //查询入库单是否审核 string SqlAuditSel = "select F_Status from PI_Head where F_Id='" + stockinfo[0].F_HId + "'"; string AuditState = this.GetDataTableBySql(SqlAuditSel).Rows[0][0].ToString(); if (AuditState == "0") { return("该入库单未审核,不能进行入库操作"); } //查询库存表是否存在该仓库中的产品 foreach (PI_BodyInfo item in stockinfo) { SearchCondition condtion = new SearchCondition(); condtion.AddCondition("F_GoodsId", item.F_GoodsId, SqlOperator.Equal); condtion.AddCondition("F_WarehouseId", item.F_WarehouseId, SqlOperator.Equal); List <Sys_StockInfo> stock = BLLFactory <Sys_Stock> .Instance.Find(condtion.BuildConditionSql().Replace("Where (1=1) AND ", string.Empty)); if (stock == null) { item.IsHave = false; } else { item.IsHave = true; item.StockID = stock[0].F_Id; item.StockNumber = stock[0].F_Number; } } foreach (PI_BodyInfo item in stockinfo) { //判断是否入库 PI_BodyInfo binfo = BLLFactory <PI_Body> .Instance.FindByID(item.F_Id); if (binfo.F_AlreadyOperatedNum == "") { binfo.F_AlreadyOperatedNum = "0"; } if (int.Parse(binfo.F_AlreadyOperatedNum) > 0) { return("该单据已入库,不能重复执行入库操作"); } //查询库存表是否存在该仓库中的产品 //没有 if (!item.IsHave) { //新添加一条数据 Sys_StockInfo entity = new Sys_StockInfo(); entity.F_Id = Guid.NewGuid().ToString(); entity.F_Batch = item.F_OrderNo; entity.F_CargoPositionId = item.F_CargoPositionId; entity.F_CargoPositionName = item.F_CargoPositionName; entity.F_WarehouseId = item.F_WarehouseId; entity.F_WarehouseName = item.F_WarehouseName; entity.F_GoodsName = item.F_GoodsName; entity.F_GoodsId = item.F_GoodsId; entity.F_SpecifModel = item.F_SpecifModel; entity.F_SellingPrice = item.F_SellingPrice; entity.F_PurchasePrice = item.F_PurchasePrice; entity.F_Unit = item.F_Unit; entity.F_Number = item.F_InStockNum; Sys_Stock.Instance.Insert(entity, dbtran.Transaction); //添加履历 Sys_InRecordsInfo inRec = new Sys_InRecordsInfo(); inRec.F_Id = Guid.NewGuid().ToString(); inRec.F_WarehouseId = item.F_WarehouseId; inRec.F_WarehouseName = item.F_WarehouseName; inRec.F_GoodsName = item.F_GoodsName; inRec.F_GoodsId = item.F_GoodsId; inRec.F_CargoPositionId = item.F_CargoPositionId; inRec.F_CargoPositionName = item.F_CargoPositionName; inRec.F_SpecifModel = item.F_SpecifModel; inRec.F_SellingPrice = item.F_SellingPrice; inRec.F_PurchasePrice = item.F_PurchasePrice; inRec.F_Unit = item.F_Unit; inRec.F_InStockNum = item.F_InStockNum; inRec.F_CreatorTime = DateTime.Now; Sys_InRecords.Instance.Insert(inRec, dbtran.Transaction); //更新子表入库状态 Hashtable hash = new Hashtable(); hash.Add("F_AlreadyOperatedNum", 1); PI_Body.Instance.Update(item.F_Id, hash, dbtran.Transaction); //更新主表入库状态 hash = new Hashtable(); hash.Add("F_State", 1); PI_Head.Instance.Update(item.F_HId, hash, dbtran.Transaction); } else { //更新前库存数量 Hashtable hash = new Hashtable(); hash.Add("F_Number", item.StockNumber + item.F_InStockNum); Sys_Stock.Instance.Update(item.StockID, hash, dbtran.Transaction); for (int i = 0; i < stockinfo.Count; i++) { if (stockinfo[i].StockID == item.StockID) { stockinfo[i].StockNumber += item.F_InStockNum; } } //更新子表入库状态 hash = new Hashtable(); hash.Add("F_AlreadyOperatedNum", 1); PI_Body.Instance.Update(item.F_Id, hash, dbtran.Transaction); //更新主表入库状态 hash = new Hashtable(); hash.Add("F_State", 1); PI_Head.Instance.Update(item.F_HId, hash, dbtran.Transaction); //添加履历 Sys_InRecordsInfo inRec = new Sys_InRecordsInfo(); inRec.F_Id = Guid.NewGuid().ToString(); inRec.F_WarehouseId = item.F_WarehouseId; inRec.F_WarehouseName = item.F_WarehouseName; inRec.F_GoodsName = item.F_GoodsName; inRec.F_GoodsId = item.F_GoodsId; inRec.F_CargoPositionId = item.F_CargoPositionId; inRec.F_CargoPositionName = item.F_CargoPositionName; inRec.F_SpecifModel = item.F_SpecifModel; inRec.F_SellingPrice = item.F_SellingPrice; inRec.F_PurchasePrice = item.F_PurchasePrice; inRec.F_Unit = item.F_Unit; inRec.F_InStockNum = item.F_InStockNum; inRec.F_CreatorTime = DateTime.Now; Sys_InRecords.Instance.Insert(inRec, dbtran.Transaction); } } dbtran.Commit(); return("操作成功"); } catch (Exception ex) { dbtran.RollBack(); return("操作失败"); throw ex; } } //try //{ // //循环获取子表信息 // for (int i = 0; i < stockinfo.Count; i++) // { // string SqlAuditSel = "select F_Status from PI_Head where F_Id='" + stockinfo[i].F_HId + "'"; // string AuditState = this.GetDataTableBySql(SqlAuditSel).Rows[0][0].ToString(); // if (AuditState == "0") // { // return "该入库单未审核,不能进行入库操作"; // } // string state = "select F_AlreadyOperatedNum from PI_Body where F_Id='" + stockinfo[i].F_Id + "'"; // DataTable dt = this.GetDataTableBySql(state); // //判断是否已入库 // string AoNum = dt.Rows[0][0].ToString(); // if (AoNum == "") // { // AoNum = "0"; // } // if (int.Parse(AoNum) > 0) // { // return "该单据已入库,不能重复执行入库操作"; // } // //查询库存表是否存在该仓库中的产品 // string sql = "select F_Id,F_Number from Sys_Stock where F_GoodsId='" + stockinfo[i].F_GoodsId + "' and F_WarehouseId='" + stockinfo[i].F_WarehouseId + "'"; // //如果没有则添加一条数据 // if (this.GetDataTableBySql(sql).Rows.Count == 0) // { // //新添加一条数据 // Sys_StockInfo entity = new Sys_StockInfo(); // entity.F_Id = Guid.NewGuid().ToString(); // entity.F_Batch = stockinfo[i].F_OrderNo; // entity.F_CargoPositionId = stockinfo[i].F_CargoPositionId; // entity.F_CargoPositionName = stockinfo[i].F_CargoPositionName; // entity.F_WarehouseId = stockinfo[i].F_WarehouseId; // entity.F_WarehouseName = stockinfo[i].F_WarehouseName; // entity.F_GoodsName = stockinfo[i].F_GoodsName; // entity.F_GoodsId = stockinfo[i].F_GoodsId; // entity.F_SpecifModel = stockinfo[i].F_SpecifModel; // entity.F_SellingPrice = stockinfo[i].F_SellingPrice; // entity.F_PurchasePrice = stockinfo[i].F_PurchasePrice; // entity.F_Unit = stockinfo[i].F_Unit; // entity.F_Number = stockinfo[i].F_InStockNum; // Sys_Stock.Instance.Insert(entity); // //添加履历 // Sys_InRecordsInfo inRec = new Sys_InRecordsInfo(); // inRec.F_Id = Guid.NewGuid().ToString(); // inRec.F_WarehouseId = stockinfo[i].F_WarehouseId; // inRec.F_WarehouseName = stockinfo[i].F_WarehouseName; // inRec.F_GoodsName = stockinfo[i].F_GoodsName; // inRec.F_GoodsId = stockinfo[i].F_GoodsId; // inRec.F_CargoPositionId = stockinfo[i].F_CargoPositionId; // inRec.F_CargoPositionName = stockinfo[i].F_CargoPositionName; // inRec.F_SpecifModel = stockinfo[i].F_SpecifModel; // inRec.F_SellingPrice = stockinfo[i].F_SellingPrice; // inRec.F_PurchasePrice = stockinfo[i].F_PurchasePrice; // inRec.F_Unit = stockinfo[i].F_Unit; // inRec.F_InStockNum = stockinfo[i].F_InStockNum; // inRec.F_CreatorTime = DateTime.Now; // Sys_InRecords.Instance.Insert(inRec); // //更新子表入库状态 // string upState = "update PI_Body set F_AlreadyOperatedNum='1' where F_Id='" + stockinfo[i].F_Id + "'"; // Hashtable hash = new Hashtable(); // base.ExecuteNonQuery(upState, hash); // //更新主表入库状态 // string upStateH = "update PI_Head set F_State='1' where F_Id='" + stockinfo[i].F_HId + "'"; // Hashtable hash1 = new Hashtable(); // base.ExecuteNonQuery(upStateH, hash1); // } // //存在就更新库存 // else // { // //更新前库存数量 // int oldnum = int.Parse(this.GetDataTableBySql(sql).Rows[0][1].ToString()); // //要入库的数量 // int instockNum = stockinfo[i].F_InStockNum; // //更新后库存数量 // int num = oldnum + instockNum; // string Str = "update Sys_Stock set F_Number='" + num + "' where F_Id='" + this.GetDataTableBySql(sql).Rows[0][0].ToString() + "'"; // Hashtable hash = new Hashtable(); // base.ExecuteNonQuery(Str, hash); // //更新子表入库状态 // string upState = "update PI_Body set F_AlreadyOperatedNum='1' where F_Id='" + stockinfo[i].F_Id + "'"; // Hashtable hash1 = new Hashtable(); // base.ExecuteNonQuery(upState, hash1); // //更新主表入库状态 // string upStateH = "update PI_Head set F_State='1' where F_Id='" + stockinfo[i].F_HId + "'"; // Hashtable hash2 = new Hashtable(); // base.ExecuteNonQuery(upStateH, hash2); // //添加履历 // Sys_InRecordsInfo inRec = new Sys_InRecordsInfo(); // inRec.F_Id = Guid.NewGuid().ToString(); // inRec.F_WarehouseId = stockinfo[i].F_WarehouseId; // inRec.F_WarehouseName = stockinfo[i].F_WarehouseName; // inRec.F_GoodsName = stockinfo[i].F_GoodsName; // inRec.F_GoodsId = stockinfo[i].F_GoodsId; // inRec.F_CargoPositionId = stockinfo[i].F_CargoPositionId; // inRec.F_CargoPositionName = stockinfo[i].F_CargoPositionName; // inRec.F_SpecifModel = stockinfo[i].F_SpecifModel; // inRec.F_SellingPrice = stockinfo[i].F_SellingPrice; // inRec.F_PurchasePrice = stockinfo[i].F_PurchasePrice; // inRec.F_Unit = stockinfo[i].F_Unit; // inRec.F_InStockNum = stockinfo[i].F_InStockNum; // inRec.F_CreatorTime = DateTime.Now; // Sys_InRecords.Instance.Insert(inRec); // } // } // return "操作成功"; //} //catch (Exception ex) //{ // throw ex; //} }
private void Cx() { try { SearchCondition searchObj = new SearchCondition(); searchObj.AddCondition("a.xmbm", txtXmbm.Text, SqlOperator.Like); searchObj.AddCondition("a.cno", txtCno.Text, SqlOperator.Equal); searchObj.AddCondition("d.cPsn_Name", txtFzr.Text, SqlOperator.Equal); searchObj.AddCondition("a.xmzt", cmbZt.Text, SqlOperator.Equal); searchObj.AddCondition("a.changdi", cmbLoc.Text, SqlOperator.Equal); searchObj.AddCondition("xmrq", dateTimePicker1.Value.ToString("yyyy-MM-dd"), SqlOperator.MoreThanOrEqual, dateTimePicker1.Checked == false); searchObj.AddCondition("xmrq", dateTimePicker2.Value.ToString("yyyy-MM-dd"), SqlOperator.LessThanOrEqual, dateTimePicker2.Checked == false); searchObj.AddCondition("csumstatus", comboBox1.Text, SqlOperator.Equal); string conditionSql = searchObj.BuildConditionSql(2); if (!string.IsNullOrEmpty(txtcInvocde.Text)) { conditionSql += string.Format(" and (a.cas like '{0}%' or a.cinvaddcode like '{0}%')", txtcInvocde.Text); } string SQL = @"select a.cNo 立项书编号,a.xmmc 项目类型,a.xmbm 项目编码, csocode 销售订单号, a.cas 存货编码,a.cinvaddcode cas, a.xmrq 项目立项日期,a.denddate 预计结束日期,a.quantity 本次立项书数量, a.guige 规格,a.changdi 项目地点,a.tuanduijj 项目奖金,c.cPsn_Name 项目管理员,d.cPsn_Name 项目负责人,a.xmzt 项目状态,csumstatus 项目执行状态, (select zyxm+',' from LK1_XM_xzr WHERE LK1_0007_E001_PK =a.LK1_0007_E001_PK for xml path('')) 项目协助人, a.xmjzbg 项目进展报告, su.dsumsl 实际产品数量,su.csumgg 实际规格,su.csumyield 实际收率,a.changdi 项目地点, a.cpmc 产品名称,a.cas CASNo,a.cinvaddcode,su.dsumdate 项目实际结束日期, su.dsumcyc 实际周期,su.bcprk 产品是否入库,su.bputu 是否提交谱图, su.bsyylrk 剩余原料是否入库,su.bzjtrk 可提供中间体是否入库,su.bmulu 是否提交中间体目录, su.btjbg 是否提交项目报告,su.syjlbbm 实验记录本编号,su.btjsyjkb 是否提交实验记录本,su.csumprize 实际奖金,lxs.lxje 立项金额,a.LK1_0007_E001_PK ,su.id, a.cbaomi 是否保密 from LK_XM_LX a LEFT JOIN dbo.zdy_lk_projectsum su ON a.cNo =su.lxscno left join hr_hi_person c on a.xmgly = c.cPsn_Num left join hr_hi_person d on a.fzr = d.cPsn_Num left join (select a.cNo ,sum(isnull(iprice,0) +isnull(zsprice,0)+isnull(fdprice,0)) lxje from LK_XM_LX a left join LK1_XM_BOM b on a.LK1_0007_E001_PK = b.LK1_0007_E001_PK group by a.cNo ) lxs on a.cNo =lxs.cno where 1=1 "; //加一个 string sql = "select cSysUserName from UA_User where cSysUserName is not null and cUser_Name='" + canshu.userName + "'"; DataTable dt = DbHelper.ExecuteTable(sql); string cQx; if (dt.Rows.Count > 0) { cQx = DbHelper.GetDbString(dt.Rows[0]["cSysUserName"]); } else { cQx = "0"; } if (canshu.userName != "demo" && cQx != "1" && cQx != "2") { //SQL = SQL + string.Format(" and (d.cPsn_Name='{0}' or c.cPsn_Name ='{1}') ", canshu.userName, canshu.userName); SQL = SQL + string.Format(" and (a.xzr like '%{0}/%' or a.xmgly='{0}' or a.fzr='{0}' )", canshu.u8Login.cUserId); } SQL = SQL + conditionSql; gridControl1.DataSource = DbHelper.ExecuteTable(SQL); } catch (Exception EX) { MessageBox.Show(EX.Message); } }
public void UpMark(string keyValue, string Name, bool State) { using (DbTransactionScope <Mst_WarehouseInfo> dbtran = base.CreateTransactionScope()) { try { Mst_WarehouseInfo info = BLLFactory <Mst_Warehouse> .Instance.FindByID(keyValue); Hashtable hash = new Hashtable(); //判断是否是仓库仓库做操作 if (Name == "F_EnabledMark") { hash.Add("F_EnabledMark", State); //如果是禁用仓库,便禁用此仓库下的货位 if (!State) { hash.Add("F_CarGoMark", State); BLLFactory <Mst_Warehouse> .Instance.Update(info.F_Id, hash, dbtran.Transaction); SearchCondition search = new SearchCondition(); search.AddCondition("F_WarehouseId", keyValue, SqlOperator.Equal); List <Mst_CargoPositionInfo> CarInfo = BLLFactory <Mst_CargoPosition> .Instance.Find(search.BuildConditionSql().Replace("Where (1=1) AND ", string.Empty).Replace("Where (1=1)", " ( 1 = 1 ) ")); foreach (Mst_CargoPositionInfo item in CarInfo) { hash = new Hashtable(); hash.Add("F_EnabledMark", State); Mst_CargoPosition.Instance.Update(item.F_Id, hash, dbtran.Transaction); } } } else { hash.Add("F_CarGoMark", State); BLLFactory <Mst_Warehouse> .Instance.Update(info.F_Id, hash); } dbtran.Commit(); } catch (Exception) { dbtran.RollBack(); throw; } } }
/// <summary> /// 批量删除主子表 /// </summary> /// <param name="keyValue"></param> public void DeleteBatch(string keyValue, bool bLogicDelete) { using (DbTransactionScope <Sys_VouchTypeInfo> dbtran = base.CreateTransactionScope()) { try { if (bLogicDelete) { //逻辑删除v //UPDATE字段 Hashtable hash = new Hashtable(); hash.Add("字段名", "修改后的值"); this.Update(keyValue, hash, dbtran.Transaction); //UPDATE 对象 Sys_VouchTypeInfo info = this.FindByID(keyValue, dbtran.Transaction); info.F_DeleteMark = false; info.F_DeleteTime = DateTime.Now; this.Update(info, keyValue, dbtran.Transaction); //获取所有的子表信息 SearchCondition c = new SearchCondition(); c.AddCondition("F_VouchId", keyValue, SqlOperator.Equal); List <Sys_VouchTypeDefaultInfo> details = Sys_VouchTypeDefault.Instance.Find(c.BuildConditionSql()); foreach (Sys_VouchTypeDefaultInfo d in details) { d.F_DeleteMark = false; d.F_DeleteTime = DateTime.Now; Sys_VouchTypeDefault.Instance.Update(d, d.F_Id, dbtran.Transaction); } //sql方式update //更新主表状态删除标志状态 string sql = "UPDATE Sys_VouchType SET DeleteMark =1 WHERE F_Id = @F_Id"; Hashtable parms = new Hashtable(); parms.Add("F_Id", keyValue); base.ExecuteNonQuery(sql, parms, dbtran.Transaction); //更新子表删除标志状态 sql = "UPDATE Sys_VouchTypeDefault SET DeleteMark =1 WHERE F_VouchId = @F_Id"; base.ExecuteNonQuery(sql, parms, dbtran.Transaction); } else { //物理删除 //删除 sys_VouchType this.Delete(keyValue, dbtran.Transaction); //删除 sys_VouchTypeDefault SearchCondition condition = new SearchCondition(); condition.AddCondition("F_VouchId", keyValue, SqlOperator.Equal); Sys_VouchTypeDefault.Instance.DeleteByCondition(condition.BuildConditionSql().Replace("Where (1=1) AND ", string.Empty), dbtran.Transaction); } dbtran.Commit(); } catch (Exception ex) { dbtran.RollBack(); throw ex; } } }
public string OutStock(string Batch, string id) { using (DbTransactionScope <Allocation_BodyInfo> dbtran = base.CreateTransactionScope()) { try { //查询子表信息 SearchCondition condition = new SearchCondition(); condition.AddCondition("F_Id", id, SqlOperator.Equal); Allocation_BodyInfo bodyinfo = BLLFactory <Allocation_Body> .Instance.Find(condition.BuildConditionSql().Replace("Where (1=1) AND ", string.Empty))[0]; //查询主表判断是否审核 condition = new SearchCondition(); condition.AddCondition("F_Id", bodyinfo.F_HId, SqlOperator.Equal); Allocation_HeadInfo headinfo = BLLFactory <Allocation_Head> .Instance.Find(condition.BuildConditionSql().Replace("Where (1=1) AND ", string.Empty))[0]; if (headinfo.F_Status == 0) { return("该调拨单未审核,不能进行出库操作"); } //判断是否出库 if (bodyinfo.F_FreeTerm1 == "") //F_FreeTerm1--0未出库 1已出库 { bodyinfo.F_FreeTerm1 = "0"; } if (int.Parse(bodyinfo.F_FreeTerm1) > 0) { return("该单据已出库,不能重复执行出库操作"); } //查询库存表是否存在该仓库中的产品 condition = new SearchCondition(); condition.AddCondition("F_GoodsId", bodyinfo.F_GoodsId, SqlOperator.Equal); condition.AddCondition("F_WarehouseId", bodyinfo.F_OutWareId, SqlOperator.Equal); List <Sys_StockInfo> stock = BLLFactory <Sys_Stock> .Instance.Find(condition.BuildConditionSql().Replace("Where (1=1) AND ", string.Empty)); if (stock.Count == 0) { return("该仓库无此产品"); } //判断库存数量是否足够 if (stock[0].F_Number > bodyinfo.F_DbNum) { //扣减库存 Hashtable hash = new Hashtable(); hash.Add("F_Number", stock[0].F_Number - bodyinfo.F_DbNum); Sys_Stock.Instance.Update(stock[0].F_Id, hash, dbtran.Transaction); //更新出库状态 hash = new Hashtable(); hash.Add("F_FreeTerm1", 1); Allocation_Body.Instance.Update(bodyinfo.F_Id, hash, dbtran.Transaction); } else { return(bodyinfo.F_OutWareName + "仓库库存不足,当前产品" + bodyinfo.F_GoodsName + "库存为" + stock[0].F_Number); } dbtran.Commit(); return("操作成功"); } catch (Exception ex) { dbtran.RollBack(); return("操作失败"); throw ex; } } }
/// <summary> /// 产品入库操作 /// </summary> /// <param name="Batch"></param> /// <param name="stockinfo"></param> /// <returns></returns> public string InStock(string Batch, string id) { using (DbTransactionScope <Allocation_BodyInfo> dbtran = base.CreateTransactionScope()) { try { //查询子表信息 SearchCondition condition = new SearchCondition(); condition.AddCondition("F_Id", id, SqlOperator.Equal); Allocation_BodyInfo bodyinfo = BLLFactory <Allocation_Body> .Instance.Find(condition.BuildConditionSql().Replace("Where (1=1) AND ", string.Empty))[0]; //查询主表判断是否审核 condition = new SearchCondition(); condition.AddCondition("F_Id", bodyinfo.F_HId, SqlOperator.Equal); Allocation_HeadInfo headinfo = BLLFactory <Allocation_Head> .Instance.Find(condition.BuildConditionSql().Replace("Where (1=1) AND ", string.Empty))[0]; if (headinfo.F_Status == 0) { return("该调拨单未审核,不能进行出库操作"); } //判断是否已入库 if (bodyinfo.F_AlreadyOperatedNum == null)//F_AlreadyOperatedNum--0未入库 1已入库 { bodyinfo.F_AlreadyOperatedNum = 0; } if (bodyinfo.F_AlreadyOperatedNum > 0) { return("该单据已入库,不能重复执行入库操作"); } //判断该调拨单是否出库 if (bodyinfo.F_FreeTerm1 == null)//F_FreeTerm1--0未出库 1已出库 { bodyinfo.F_FreeTerm1 = "0"; return("调拨单中产品未出库,不能进行入库操作"); } if (int.Parse(bodyinfo.F_FreeTerm1) > 0) { //查询库存表是否存在该仓库中的产品 condition = new SearchCondition(); condition.AddCondition("F_GoodsId", bodyinfo.F_GoodsId, SqlOperator.Equal); condition.AddCondition("F_WarehouseId", bodyinfo.F_InWareId, SqlOperator.Equal); List <Sys_StockInfo> stock = BLLFactory <Sys_Stock> .Instance.Find(condition.BuildConditionSql().Replace("Where (1=1) AND ", string.Empty)); //如果不存在 if (stock.Count == 0) { //新添加一条数据 Sys_StockInfo entity = new Sys_StockInfo(); entity.F_Id = Guid.NewGuid().ToString(); entity.F_GoodsId = bodyinfo.F_GoodsId; entity.F_GoodsName = bodyinfo.F_GoodsName; entity.F_WarehouseId = bodyinfo.F_InWareId; entity.F_WarehouseName = bodyinfo.F_InWareName; entity.F_Number = bodyinfo.F_DbNum; Sys_Stock.Instance.Insert(entity, dbtran.Transaction); //添加履历 Sys_AllocationHistoryInfo Dbinfo = new Sys_AllocationHistoryInfo(); Dbinfo.F_Id = Guid.NewGuid().ToString(); Dbinfo.F_GoodsId = bodyinfo.F_GoodsId; Dbinfo.F_InWareName = bodyinfo.F_InWareName; Dbinfo.F_GoodsName = bodyinfo.F_GoodsName; Dbinfo.F_OutWareId = bodyinfo.F_OutWareId; Dbinfo.F_InWareId = bodyinfo.F_InWareId; Dbinfo.F_OutWareName = bodyinfo.F_OutWareName; Dbinfo.F_Unit = bodyinfo.F_Unit; Dbinfo.F_DBNum = bodyinfo.F_DbNum; Dbinfo.F_SpecifModel = bodyinfo.F_SpecifModel; Dbinfo.F_CreatorTime = DateTime.Now; Sys_AllocationHistory.Instance.Insert(Dbinfo, dbtran.Transaction); //更新入库状态 Hashtable hash = new Hashtable(); hash.Add("F_AlreadyOperatedNum", 1); Allocation_Body.Instance.Update(bodyinfo.F_Id, hash, dbtran.Transaction); } //如果存在 else { //增加库存 Hashtable hash = new Hashtable(); hash.Add("F_Number", stock[0].F_Number + bodyinfo.F_DbNum); Sys_Stock.Instance.Update(stock[0].F_Id, hash, dbtran.Transaction); //更新入库状态 hash = new Hashtable(); hash.Add("F_AlreadyOperatedNum", 1); Allocation_Body.Instance.Update(bodyinfo.F_Id, hash, dbtran.Transaction); //添加履历 Sys_AllocationHistoryInfo Dbinfo = new Sys_AllocationHistoryInfo(); Dbinfo.F_Id = Guid.NewGuid().ToString(); Dbinfo.F_GoodsId = bodyinfo.F_GoodsId; Dbinfo.F_InWareName = bodyinfo.F_InWareName; Dbinfo.F_GoodsName = bodyinfo.F_GoodsName; Dbinfo.F_OutWareId = bodyinfo.F_OutWareId; Dbinfo.F_InWareId = bodyinfo.F_InWareId; Dbinfo.F_OutWareName = bodyinfo.F_OutWareName; Dbinfo.F_Unit = bodyinfo.F_Unit; Dbinfo.F_DBNum = bodyinfo.F_DbNum; Dbinfo.F_SpecifModel = bodyinfo.F_SpecifModel; Dbinfo.F_CreatorTime = DateTime.Now; Sys_AllocationHistory.Instance.Insert(Dbinfo, dbtran.Transaction); } } dbtran.Commit(); return("操作成功"); } catch (Exception ex) { dbtran.RollBack(); return("操作失败"); throw ex; } } }
/// <summary> /// 客户状态的处理 /// </summary> private void AddStatusTree2(List <SystemTreeNodeInfo> nodeList, TreeNodeInfo treeNode, int i) { foreach (SystemTreeNodeInfo nodeInfo in nodeList) { if (ContainTree(nodeInfo.ID)) { TreeNodeInfo subNode = new TreeNodeInfo(nodeInfo.TreeName, i); subNode.Tag = nodeInfo.SpecialTag;//用来做一定的标识 //绑定数量 if (!string.IsNullOrWhiteSpace(nodeInfo.SpecialTag)) { var filter = nodeInfo.SpecialTag; //如果过滤条件不为空,那么需要进行过滤 if (!string.IsNullOrEmpty(ShareUserCondition)) { filter = string.Format(" {0} AND {1}", ShareUserCondition, filter); } var count = BLLFactory <Customer> .Instance.GetRecordCount(filter); subNode.Text += string.Format("({0})", count); } else { DateTime dt = DateTime.Now.ToString("yyyy-MM-dd").ToDateTime(); //当前日期 DateTime startWeek = dt.AddDays(1 - Convert.ToInt32(dt.DayOfWeek.ToString("d"))); //本周周一 DateTime endWeek = startWeek.AddDays(6); //本周周日 DateTime startMonth = dt.AddDays(1 - dt.Day); //本月月初 DateTime endMonth = startMonth.AddMonths(1).AddDays(-1); //本月月末 bool statusFlag = false; SearchCondition condition = new SearchCondition(); switch (nodeInfo.TreeName) { //本日联系客户,本周联系客户,本月联系客户,上月联系客户,本日新增客户,本周新增客户,本月新增客户,上月新增客户 #region 常规客户状态类型 case "本日联系客户": statusFlag = true; condition.AddCondition("LastContactDate", dt, SqlOperator.MoreThanOrEqual) .AddCondition("LastContactDate", dt.AddDays(1), SqlOperator.LessThan); break; case "本周联系客户": statusFlag = true; condition.AddCondition("LastContactDate", startWeek, SqlOperator.MoreThanOrEqual) .AddCondition("LastContactDate", endWeek.AddDays(1), SqlOperator.LessThan); break; case "本月联系客户": statusFlag = true; condition.AddCondition("LastContactDate", startMonth, SqlOperator.MoreThanOrEqual) .AddCondition("LastContactDate", endMonth.AddDays(1), SqlOperator.LessThan); break; case "上月联系客户": statusFlag = true; condition.AddCondition("LastContactDate", startMonth.AddMonths(-1), SqlOperator.MoreThanOrEqual) .AddCondition("LastContactDate", endMonth.AddMonths(-1).AddDays(1), SqlOperator.LessThan); break; case "本日新增客户": statusFlag = true; condition.AddCondition("CreateTime", dt, SqlOperator.MoreThanOrEqual) .AddCondition("CreateTime", dt.AddDays(1), SqlOperator.LessThan); break; case "本周新增客户": statusFlag = true; condition.AddCondition("CreateTime", startWeek, SqlOperator.MoreThanOrEqual) .AddCondition("CreateTime", endWeek.AddDays(1), SqlOperator.LessThan); break; case "本月新增客户": statusFlag = true; condition.AddCondition("CreateTime", startMonth, SqlOperator.MoreThanOrEqual) .AddCondition("CreateTime", endMonth.AddDays(1), SqlOperator.LessThan); break; case "上月新增客户": statusFlag = true; condition.AddCondition("CreateTime", startMonth.AddMonths(-1), SqlOperator.MoreThanOrEqual) .AddCondition("CreateTime", endMonth.AddMonths(-1).AddDays(1), SqlOperator.LessThan); break; #endregion } if (statusFlag) { var filter = condition.BuildConditionSql().Replace("Where", ""); subNode.Tag = filter; //计算数量 //如果过滤条件不为空,那么需要进行过滤 if (!string.IsNullOrEmpty(ShareUserCondition)) { filter = string.Format(" {0} AND {1}", ShareUserCondition, filter); } var count = BLLFactory <Customer> .Instance.GetRecordCount(filter); subNode.Text += string.Format("({0})", count); } } treeNode.Nodes.Add(subNode); AddStatusTree2(nodeInfo.Children, subNode, i + 1); } } }
/// <summary> /// 保存 /// </summary> /// <param name="model"></param> /// <param name="fromList"></param> /// <param name="fromInsList"></param> /// <param name="buttonList"></param> /// <returns></returns> public string Save(Sys_ModuleInfo model, List <Sys_ModuleFormInfo> fromList, List <Sys_ModuleFormInstanceInfo> fromInsList, List <Sys_ModuleButtonInfo> buttonList) { using (DbTransactionScope <Sys_ModuleInfo> dbtran = base.CreateTransactionScope()) { try { //添加或修改主表 BLLFactory <Sys_Module> .Instance.InsertUpdate(model, model.F_Id, dbtran.Transaction); //先删除子表再添加子表 SearchCondition search = new SearchCondition(); search.AddCondition("F_ModuleId", model.F_Id, SqlOperator.Equal); BLLFactory <Sys_ModuleButton> .Instance.DeleteByCondition(search.BuildConditionSql().Replace(" Where (1=1) AND", string.Empty), dbtran.Transaction); //找到对应的from界面 List <Sys_ModuleFormInfo> GetfromList = BLLFactory <Sys_ModuleForm> .Instance.Find(search.BuildConditionSql().Replace(" Where (1=1) AND", string.Empty), dbtran.Transaction); if (GetfromList != null)//循环删除FromInstance { foreach (var item in GetfromList) { search = new SearchCondition(); search.AddCondition("F_FormId", item.F_Id, SqlOperator.Equal); BLLFactory <Sys_ModuleFormInstance> .Instance.DeleteByCondition(search.BuildConditionSql().Replace(" Where (1=1) AND", string.Empty), dbtran.Transaction); } } ///删除from界面 BLLFactory <Sys_ModuleForm> .Instance.DeleteByCondition(search.BuildConditionSql().Replace(" Where (1=1) AND", string.Empty), dbtran.Transaction); dbtran.Commit(); //添加子表 if (fromList != null && fromList.Count > 0) { BLLFactory <Sys_ModuleForm> .Instance.InsertRange(fromList); } if (fromInsList != null && fromInsList.Count > 0) { BLLFactory <Sys_ModuleFormInstance> .Instance.InsertRange(fromInsList); } if (buttonList != null && buttonList.Count > 0) { BLLFactory <Sys_ModuleButton> .Instance.InsertRange(buttonList); } dbtran.Commit(); return("1"); } catch (Exception) { dbtran.RollBack(); throw; } } }
/// <summary> /// 获取分页操作的查询条件 /// </summary> /// <returns></returns> protected virtual string GetPagerCondition() { string where = ""; //增加一个CustomedCondition条件,根据客户这个条件进行查询 string CustomedCondition = Request["CustomedCondition"] ?? ""; if (!string.IsNullOrWhiteSpace(CustomedCondition)) { where = CustomedCondition;//直接使用条件 } else { #region 根据数据库字段列,对所有可能的参数进行获值,然后构建查询条件 SearchCondition condition = new SearchCondition(); DataTable dt = baseBLL.GetFieldTypeList(); foreach (DataRow dr in dt.Rows) { string columnName = dr["ColumnName"].ToString(); string dataType = dr["DataType"].ToString(); //字段增加WHC_前缀字符,避免传递如URL这样的Request关键字冲突 string columnValue = Request["WHC_" + columnName] ?? ""; //对于数值型,如果是显示声明相等的,一般是外键引用,需要特殊处理 bool hasEqualValue = columnValue.StartsWith("="); if (IsDateTime(dataType)) { condition.AddDateCondition(columnName, columnValue); } else if (IsNumericType(dataType)) { //如果数据库是数值类型,而传入的值是true或者false,那么代表数据库的参考值为1,0,需要进行转换 bool boolValue = false; bool isBoolenValue = bool.TryParse(columnValue, out boolValue); if (isBoolenValue) { condition.AddCondition(columnName, boolValue ? 1 : 0, SqlOperator.Equal); } else if (hasEqualValue) { columnValue = columnValue.Substring(columnValue.IndexOf("=") + 1); condition.AddCondition(columnName, columnValue, SqlOperator.Equal); } else { condition.AddNumberCondition(columnName, columnValue); } } else { if (ValidateUtil.IsNumeric(columnValue)) { condition.AddCondition(columnName, columnValue, SqlOperator.Equal); } else { condition.AddCondition(columnName, columnValue, SqlOperator.Like); } } } #endregion #region MyRegion //string SystemType_ID = Request["SystemType_ID"] ?? ""; //string LoginName = Request["LoginName"] ?? ""; //string FullName = Request["FullName"] ?? ""; //string Note = Request["Note"] ?? ""; //string IPAddress = Request["IPAddress"] ?? ""; //string MacAddress = Request["MacAddress"] ?? ""; //string LastUpdated = Request["LastUpdated"] ?? ""; //SearchCondition condition = new SearchCondition(); //condition.AddCondition("SystemType_ID", SystemType_ID, SqlOperator.Like); //condition.AddCondition("LoginName", LoginName, SqlOperator.Like); //condition.AddCondition("FullName", FullName, SqlOperator.Like); //condition.AddCondition("Note", Note, SqlOperator.Like); //condition.AddCondition("IPAddress", IPAddress, SqlOperator.Like); //condition.AddCondition("MacAddress", MacAddress, SqlOperator.Like); //condition.AddDateCondition("LastUpdated", LastUpdated); #endregion where = condition.BuildConditionSql().Replace("Where", ""); } return(where); }
/// <summary> /// 删除菜单 /// </summary> /// <param name="Id"></param> /// <returns></returns> public bool DeleteFromById(string Id) { using (DbTransactionScope <Sys_ModuleInfo> dbtran = base.CreateTransactionScope()) { try { SearchCondition search = new SearchCondition(); search.AddCondition("F_ModuleId", Id, SqlOperator.Equal); BLLFactory <Sys_ModuleButton> .Instance.DeleteByCondition(search.BuildConditionSql().Replace(" Where (1=1) AND", string.Empty), dbtran.Transaction); //找到对应的from界面 List <Sys_ModuleFormInfo> GetfromList = BLLFactory <Sys_ModuleForm> .Instance.Find(search.BuildConditionSql().Replace(" Where (1=1) AND", string.Empty), dbtran.Transaction); if (GetfromList != null)//循环删除FromInstance { foreach (var item in GetfromList) { search = new SearchCondition(); search.AddCondition("F_FormId", item.F_Id, SqlOperator.Equal); BLLFactory <Sys_ModuleFormInstance> .Instance.DeleteByCondition(search.BuildConditionSql().Replace(" Where (1=1) AND", string.Empty), dbtran.Transaction); } } ///删除from界面 BLLFactory <Sys_ModuleForm> .Instance.DeleteByCondition(search.BuildConditionSql().Replace(" Where (1=1) AND", string.Empty), dbtran.Transaction); dbtran.Commit(); return(true); } catch (Exception ex) { throw; } } }
public OutStockNotice_HeadInfo Save(OutStockNotice_HeadInfo info, List <OutStockNotice_BodyInfo> BInfo) { using (DbTransactionScope <OutStockNotice_HeadInfo> dbtran = base.CreateTransactionScope()) { try { if (string.IsNullOrEmpty(info.F_EnCode)) { string orderNo = "OUTOT" + DateTime.Now.ToString("yyyyMMdd"); Hashtable hash = new Hashtable(); hash.Add("Prefix", orderNo); DataTable dt = base.StorePorcToDataTable("SYS_GENERATE_SN", hash, null, dbtran.Transaction); string SN = dt.Rows[0][0].ToString(); info.F_EnCode = SN; } else { //判断当前单据是否已经审核 var head = this.FindByID(info.F_Id, dbtran.Transaction); if (head != null && head.F_Status == 1) { throw new ApplicationException("单据已经审核!"); } } info.F_Status = 0; info.F_Verifier = ""; info.F_Veridate = null; //添加主表 OutStockNotice_Head.Instance.InsertUpdate(info, info.F_Id, dbtran.Transaction); //删除子表 SearchCondition condition = new SearchCondition(); condition.AddCondition("F_HeadId", info.F_Id, SqlOperator.Equal); OutStockNotice_Body.Instance.DeleteByCondition(condition.BuildConditionSql().Replace("Where (1=1) AND ", string.Empty), dbtran.Transaction); //循环添加子表 foreach (OutStockNotice_BodyInfo item in BInfo) { item.F_CreatorTime = DateTime.Now; item.F_CreatorUserId = info.F_CreatorUserId; item.F_Id = Guid.NewGuid().ToString(); item.F_HeadId = info.F_Id; string orderNo = "OUTOTOTB" + DateTime.Now.ToString("yyyyMMdd"); Hashtable hash = new Hashtable(); hash.Add("Prefix", orderNo); DataTable dt = base.StorePorcToDataTable("SYS_GENERATE_SN", hash, null, dbtran.Transaction); string SN = dt.Rows[0][0].ToString(); item.F_EnCode = SN; //OutStockNotice_Body.Instance.Insert(item, dbtran.Transaction); } OutStockNotice_Body.Instance.InsertRange(BInfo, dbtran.Transaction); dbtran.Commit(); return(info); } catch (Exception ex) { dbtran.RollBack(); throw ex; } } }
public override bool CheckInput() { bool result = true;//默认是可以通过 #region MyRegion if (this.txtDictType.Text.Trim().Length == 0) { MessageDxUtil.ShowWarning(Const.MsgCheckInput + lblDictType.Text.Replace(Const.MsgCheckSign, string.Empty)); this.txtDictType.Focus(); result = false; } if (this.txtValue.Text.Trim().Length == 0) { MessageDxUtil.ShowWarning(Const.MsgCheckInput + lblValue.Text.Replace(Const.MsgCheckSign, string.Empty)); this.txtValue.Focus(); result = false; } if (this.txtName.Text.Trim().Length == 0) { MessageDxUtil.ShowWarning(Const.MsgCheckInput + lblName.Text.Replace(Const.MsgCheckSign, string.Empty)); this.txtName.Focus(); result = false; } if (this.txtSeq.Text.Trim().Length == 0) { MessageDxUtil.ShowWarning(Const.MsgCheckInput + lblSeq.Text.Replace(Const.MsgCheckSign, string.Empty)); this.txtSeq.Focus(); result = false; } string Id = txtValue.Text; if (result) { if (!ValidateUtil.IsNumeric(Id)) { MessageDxUtil.ShowWarning(lblValue.Text.Replace(Const.MsgCheckSign, string.Empty) + Const.MsgErrFormatByNum); txtValue.Focus(); result = false; } } // 检查对应的值是否已经存在数据库了 if (result && string.IsNullOrEmpty(ID)) { SearchCondition condition = new SearchCondition(); condition.AddCondition("DictType_ID", Convert.ToInt32(this.txtDictType.Tag), SqlOperator.Equal); condition.AddCondition("Value", Convert.ToInt32(Id), SqlOperator.Equal); string where = condition.BuildConditionSql().Replace("Where", ""); var lst = BLLFactory <DictData> .Instance.Find(where); if (lst.Count > 0) { MessageDxUtil.ShowTips(string.Format("已存在此值域数据[字典大类编号:{0},字典值:{1},字典名称:{2}]", lst[0].DictType_ID, lst[0].Value, lst[0].Name)); this.txtValue.Focus(); result = false; } } #endregion return(result); }
/// <summary> ///审核单据 /// </summary> /// <param name="date">审核日期</param> /// <param name="Id">审核单据</param> /// <param name="user">审核人</param> public string Audit(string date, string user, string Id, List <Allocation_BodyInfo> DbInfo) { string SqlAuditSel = "select F_Status from Allocation_Head where F_Id='" + Id + "'"; string AuditState = this.GetDataTableBySql(SqlAuditSel).Rows[0][0].ToString(); if (AuditState == "1") { return("单据已被审核"); } else { using (DbTransactionScope <Allocation_HeadInfo> dbtran = base.CreateTransactionScope()) { try { Hashtable hash = new Hashtable(); List <Sys_StockInfo> StockList = BLLFactory <Sys_Stock> .Instance.GetAll(); //查询主表信息 Allocation_HeadInfo hinfo = BLLFactory <Allocation_Head> .Instance.FindByID(Id); for (int i = 0; i < DbInfo.Count; i++) { //查询子表信息 SearchCondition condition = new SearchCondition(); condition.AddCondition("F_Id", DbInfo[i].F_Id, SqlOperator.Equal); Allocation_BodyInfo bodyinfo = BLLFactory <Allocation_Body> .Instance.Find(condition.BuildConditionSql().Replace("Where (1=1) AND ", string.Empty))[0]; //判断是否出库 if (bodyinfo.F_FreeTerm1 == "") //F_FreeTerm1--0未出库 1已出库 { bodyinfo.F_FreeTerm1 = "0"; } if (int.Parse(bodyinfo.F_FreeTerm1) > 0) { return("该单据已出库,不能重复执行出库操作"); } if (bodyinfo.F_OutWareId == "" || bodyinfo.F_OutCargoPositionId == "" || bodyinfo.F_InWareId == "" || bodyinfo.F_InCargoPositionId == "") { return("该单据中仓库或仓位为空,审核未通过"); } //查询库存表是否存在该仓库中的产品 Sys_StockInfo stock = StockList.Find(u => u.F_WarehouseId == bodyinfo.F_OutWareId && u.F_CargoPositionId == bodyinfo.F_OutCargoPositionId && u.F_GoodsId == bodyinfo.F_GoodsId && u.F_Batch == bodyinfo.F_SerialNum); if (stock == null) { dbtran.RollBack(); return("该仓库无此产品"); } //判断库存数量是否足够 if (stock.F_Number > bodyinfo.F_DbNum) { //扣减库存 hash = new Hashtable(); hash.Add("F_Number", stock.F_Number - bodyinfo.F_DbNum); Sys_Stock.Instance.Update(stock.F_Id, hash, dbtran.Transaction); //添加库存履历 Sys_StockHistoryInfo instockHistory = new Sys_StockHistoryInfo(); instockHistory.F_Id = Guid.NewGuid().ToString(); instockHistory.F_WarehouseId = bodyinfo.F_OutWareId; instockHistory.F_EnCode = bodyinfo.F_OrderNo; instockHistory.F_Batch = bodyinfo.F_SerialNum; instockHistory.F_Verify = user; instockHistory.F_Maker = hinfo.F_Maker; instockHistory.F_VeriDate = DateTime.Now; instockHistory.F_WarehouseName = bodyinfo.F_OutWareName; instockHistory.F_BllCategory = "调出"; instockHistory.F_GoodsName = bodyinfo.F_GoodsName; instockHistory.F_GoodsId = bodyinfo.F_GoodsId; instockHistory.F_CargoPositionId = bodyinfo.F_OutCargoPositionId; instockHistory.F_CargoPositionName = bodyinfo.F_OutCargoPositionName; instockHistory.F_SpecifModel = bodyinfo.F_SpecifModel; instockHistory.F_Unit = bodyinfo.F_Unit; instockHistory.F_OperationNum = 0 - bodyinfo.F_DbNum; instockHistory.F_CreatorTime = DateTime.Now; Sys_StockHistory.Instance.Insert(instockHistory, dbtran.Transaction); //更新出库状态 hash = new Hashtable(); hash.Add("F_FreeTerm1", 1); Allocation_Body.Instance.Update(bodyinfo.F_Id, hash, dbtran.Transaction); } else { return(bodyinfo.F_OutWareName + "仓库库存不足,当前产品" + bodyinfo.F_GoodsName + "库存为" + stock.F_Number); } Sys_StockInfo instock = StockList.Find(u => u.F_WarehouseId == bodyinfo.F_InWareId && u.F_CargoPositionId == bodyinfo.F_InCargoPositionId && u.F_GoodsId == bodyinfo.F_GoodsId); //如果不存在 if (instock == null) { //新添加一条数据 Sys_StockInfo entity = new Sys_StockInfo(); entity.F_Id = Guid.NewGuid().ToString(); entity.F_GoodsId = bodyinfo.F_GoodsId; entity.F_GoodsName = bodyinfo.F_GoodsName; entity.F_WarehouseId = bodyinfo.F_InWareId; entity.F_WarehouseName = bodyinfo.F_InWareName; entity.F_CargoPositionId = bodyinfo.F_InCargoPositionId; entity.F_CargoPositionName = bodyinfo.F_InCargoPositionName; entity.F_Batch = bodyinfo.F_SerialNum; entity.F_Unit = bodyinfo.F_Unit; entity.F_Number = bodyinfo.F_DbNum; Sys_Stock.Instance.Insert(entity, dbtran.Transaction); //添加履历 Sys_AllocationHistoryInfo Dbinfo = new Sys_AllocationHistoryInfo(); Dbinfo.F_Id = Guid.NewGuid().ToString(); Dbinfo.F_GoodsId = bodyinfo.F_GoodsId; Dbinfo.F_InWareName = bodyinfo.F_InWareName; Dbinfo.F_EnCode = bodyinfo.F_OrderNo; Dbinfo.F_Batch = bodyinfo.F_SerialNum; Dbinfo.F_GoodsName = bodyinfo.F_GoodsName; Dbinfo.F_Verify = user; Dbinfo.F_Maker = hinfo.F_Maker; Dbinfo.F_VeriDate = DateTime.Now; Dbinfo.F_OutWareId = bodyinfo.F_OutWareId; Dbinfo.F_InWareId = bodyinfo.F_InWareId; Dbinfo.F_OutWareName = bodyinfo.F_OutWareName; Dbinfo.F_InCargoPositionId = bodyinfo.F_InCargoPositionId; Dbinfo.F_InCargoPositionName = bodyinfo.F_InCargoPositionName; Dbinfo.F_OutCargoPositionId = bodyinfo.F_OutCargoPositionId; Dbinfo.F_OutCargoPositionName = bodyinfo.F_OutCargoPositionName; Dbinfo.F_Unit = bodyinfo.F_Unit; Dbinfo.F_DBNum = bodyinfo.F_DbNum; Dbinfo.F_SpecifModel = bodyinfo.F_SpecifModel; Dbinfo.F_CreatorTime = DateTime.Now; Sys_AllocationHistory.Instance.Insert(Dbinfo, dbtran.Transaction); //添加库存履历 Sys_StockHistoryInfo instockHistory = new Sys_StockHistoryInfo(); instockHistory.F_Id = Guid.NewGuid().ToString(); instockHistory.F_WarehouseId = bodyinfo.F_OutWareId; instockHistory.F_EnCode = bodyinfo.F_OrderNo; instockHistory.F_Batch = bodyinfo.F_SerialNum; instockHistory.F_Verify = user; instockHistory.F_Maker = hinfo.F_Maker; instockHistory.F_VeriDate = DateTime.Now; instockHistory.F_WarehouseName = bodyinfo.F_InWareName; instockHistory.F_BllCategory = "调入"; instockHistory.F_GoodsName = bodyinfo.F_GoodsName; instockHistory.F_GoodsId = bodyinfo.F_GoodsId; instockHistory.F_CargoPositionId = bodyinfo.F_InCargoPositionName; instockHistory.F_CargoPositionName = bodyinfo.F_InCargoPositionId; instockHistory.F_SpecifModel = bodyinfo.F_SpecifModel; instockHistory.F_Unit = bodyinfo.F_Unit; instockHistory.F_OperationNum = bodyinfo.F_DbNum; instockHistory.F_CreatorTime = DateTime.Now; Sys_StockHistory.Instance.Insert(instockHistory, dbtran.Transaction); //更新入库状态 hash = new Hashtable(); hash.Add("F_AlreadyOperatedNum", 1); Allocation_Body.Instance.Update(bodyinfo.F_Id, hash, dbtran.Transaction); } //如果存在 else { //增加库存 hash = new Hashtable(); hash.Add("F_Number", instock.F_Number + bodyinfo.F_DbNum); Sys_Stock.Instance.Update(instock.F_Id, hash, dbtran.Transaction); //更新入库状态 hash = new Hashtable(); hash.Add("F_AlreadyOperatedNum", 1); Allocation_Body.Instance.Update(bodyinfo.F_Id, hash, dbtran.Transaction); //添加履历 Sys_AllocationHistoryInfo Dbinfo = new Sys_AllocationHistoryInfo(); Dbinfo.F_Id = Guid.NewGuid().ToString(); Dbinfo.F_GoodsId = bodyinfo.F_GoodsId; Dbinfo.F_Verify = user; Dbinfo.F_Maker = hinfo.F_Maker; Dbinfo.F_VeriDate = DateTime.Now; Dbinfo.F_EnCode = bodyinfo.F_OrderNo; Dbinfo.F_Batch = bodyinfo.F_SerialNum; Dbinfo.F_InWareName = bodyinfo.F_InWareName; Dbinfo.F_GoodsName = bodyinfo.F_GoodsName; Dbinfo.F_OutWareId = bodyinfo.F_OutWareId; Dbinfo.F_InWareId = bodyinfo.F_InWareId; Dbinfo.F_OutWareName = bodyinfo.F_OutWareName; Dbinfo.F_InCargoPositionId = bodyinfo.F_InCargoPositionId; Dbinfo.F_InCargoPositionName = bodyinfo.F_InCargoPositionName; Dbinfo.F_OutCargoPositionId = bodyinfo.F_OutCargoPositionId; Dbinfo.F_OutCargoPositionName = bodyinfo.F_OutCargoPositionName; Dbinfo.F_Unit = bodyinfo.F_Unit; Dbinfo.F_DBNum = bodyinfo.F_DbNum; Dbinfo.F_SpecifModel = bodyinfo.F_SpecifModel; Dbinfo.F_CreatorTime = DateTime.Now; Sys_AllocationHistory.Instance.Insert(Dbinfo, dbtran.Transaction); //添加库存履历 Sys_StockHistoryInfo instockHistory = new Sys_StockHistoryInfo(); instockHistory.F_Id = Guid.NewGuid().ToString(); instockHistory.F_WarehouseId = bodyinfo.F_InWareId; instockHistory.F_WarehouseName = bodyinfo.F_InWareName; instockHistory.F_EnCode = bodyinfo.F_OrderNo; instockHistory.F_Batch = bodyinfo.F_SerialNum; instockHistory.F_Verify = user; instockHistory.F_Maker = hinfo.F_Maker; instockHistory.F_VeriDate = DateTime.Now; instockHistory.F_BllCategory = "调入"; instockHistory.F_GoodsName = bodyinfo.F_GoodsName; instockHistory.F_GoodsId = bodyinfo.F_GoodsId; instockHistory.F_CargoPositionId = bodyinfo.F_InCargoPositionId; instockHistory.F_CargoPositionName = bodyinfo.F_InCargoPositionName; instockHistory.F_SpecifModel = bodyinfo.F_SpecifModel; instockHistory.F_Unit = bodyinfo.F_Unit; instockHistory.F_OperationNum = bodyinfo.F_DbNum; instockHistory.F_CreatorTime = DateTime.Now; Sys_StockHistory.Instance.Insert(instockHistory, dbtran.Transaction); } } //更新审核状态 string sql = string.Format("update Allocation_Head set F_Status=1,F_AccountDate='{0}',F_Verify='{1}' where F_Id='{2}'", date, user, Id); hash = new Hashtable(); base.ExecuteNonQuery(sql, hash, dbtran.Transaction); dbtran.Commit(); return("单据审核成功"); } catch (Exception ex) { dbtran.RollBack(); return("操作失败"); throw ex; } } } }
public async Task <KgmApiResultEntity> GetBoolPostion(string orderNo, string orderType, string PositionCode) { return(await Task.Run(() => { KgmApiResultEntity entity = new KgmApiResultEntity() { result = true }; SearchCondition search = new SearchCondition(); search.AddCondition("F_EnCode", orderNo, SqlOperator.Equal); switch (orderType.ToUpper()) { case "PI": var PIdata = BLLFactory <PI_Head> .Instance.FindSingle(search.BuildConditionSql().Replace("Where", string.Empty)); search = new SearchCondition(); search.AddCondition("F_EnCode", PositionCode, SqlOperator.Equal); search.AddCondition("F_WarehouseId", PIdata.F_WarehouseId, SqlOperator.Equal); if (BLLFactory <Mst_CargoPosition> .Instance.FindSingle(search.BuildConditionSql().Replace("Where", string.Empty)) == null) { var warehouse = BLLFactory <Mst_Warehouse> .Instance.FindByID(PIdata.F_WarehouseId); entity.result = false; entity.message = "货位编码错误或货位不属于仓库" + warehouse.F_Id; return entity; } break; case "SO": var SOdata = BLLFactory <SO_Head> .Instance.FindSingle(search.BuildConditionSql().Replace("Where", string.Empty)); search = new SearchCondition(); search.AddCondition("F_EnCode", PositionCode, SqlOperator.Equal); search.AddCondition("F_WarehouseId", SOdata.F_WarehouseId, SqlOperator.Equal); if (BLLFactory <Mst_CargoPosition> .Instance.FindSingle(search.BuildConditionSql().Replace("Where", string.Empty)) == null) { var warehouse = BLLFactory <Mst_Warehouse> .Instance.FindByID(SOdata.F_WarehouseId); entity.result = false; entity.message = "货位编码错误或货位不属于仓库" + warehouse.F_Id; return entity; } break; case "CW": var CWdata = BLLFactory <SO_Head> .Instance.FindSingle(search.BuildConditionSql().Replace("Where", string.Empty)); search = new SearchCondition(); search.AddCondition("F_EnCode", PositionCode, SqlOperator.Equal); search.AddCondition("F_WarehouseId", CWdata.F_WarehouseId, SqlOperator.Equal); if (BLLFactory <Mst_CargoPosition> .Instance.FindSingle(search.BuildConditionSql().Replace("Where", string.Empty)) == null) { var warehouse = BLLFactory <Mst_Warehouse> .Instance.FindByID(CWdata.F_WarehouseId); entity.result = false; entity.message = "货位编码错误或货位不属于仓库" + warehouse.F_Id; return entity; } break; //case "MP": // var CWdata = BLLFactory<SO_Head>.Instance.FindSingle(search.BuildConditionSql().Replace("Where", string.Empty)); // search = new SearchCondition(); // search.AddCondition("F_EnCode", PositionCode, SqlOperator.Equal); // search.AddCondition("F_WarehouseId", CWdata.F_WarehouseId, SqlOperator.Equal); // if (BLLFactory<Mst_CargoPosition>.Instance.FindSingle(search.BuildConditionSql().Replace("Where", string.Empty)) == null) // { // var warehouse = BLLFactory<Mst_Warehouse>.Instance.FindByID(CWdata.F_WarehouseId); // entity.result = false; // entity.message = "货位编码错误或货位不属于仓库" + warehouse.F_Id; // return entity; // } // break; } return entity; })); }
/// <summary> ///审核单据 /// </summary> /// <param name="date">审核日期</param> /// <param name="Id">审核单据</param> /// <param name="user">审核人</param> public string Audit(string date, string user, string Id, List <PI_ReturnBodyInfo> stockinfo) { string SqlAuditSel = "select F_Status from PI_ReturnHead where F_Id='" + Id + "'"; string AuditState = this.GetDataTableBySql(SqlAuditSel).Rows[0][0].ToString(); if (AuditState == "1") { return("单据已被审核"); } else { using (DbTransactionScope <PI_ReturnHeadInfo> dbtran = base.CreateTransactionScope()) { try { Hashtable hash = new Hashtable(); //查询所有库存信息 List <Sys_StockInfo> StockList = BLLFactory <Sys_Stock> .Instance.GetAll(); PI_ReturnHeadInfo hinfo = BLLFactory <PI_ReturnHead> .Instance.FindByID(Id); SearchCondition condition = new SearchCondition(); //condition.AddCondition("F_EnCode", hinfo.F_InStockCode, SqlOperator.Equal); //PI_HeadInfo pih = BLLFactory<PI_Head>.Instance.Find(condition.BuildConditionSql().Replace("Where (1=1) AND ", string.Empty))[0]; for (int i = 0; i < stockinfo.Count; i++) { //查询子表信息 condition = new SearchCondition(); condition.AddCondition("F_Id", stockinfo[i].F_Id, SqlOperator.Equal); PI_ReturnBodyInfo bodyinfo = BLLFactory <PI_ReturnBody> .Instance.Find(condition.BuildConditionSql().Replace("Where (1=1) AND ", string.Empty))[0]; if (bodyinfo.F_WarehouseId == "" || bodyinfo.F_CargoPositionId == "") { return("该单据中仓库或仓位为空,审核未通过"); } Sys_StockInfo stock = StockList.Find(u => u.F_WarehouseId == bodyinfo.F_WarehouseId && u.F_CargoPositionId == bodyinfo.F_CargoPositionId && u.F_GoodsId == bodyinfo.F_GoodsId && u.F_Batch == bodyinfo.F_SerialNum); //查询库存表是否存在该仓库中的产品 if (stock == null) { dbtran.RollBack(); return("该仓库无此产品"); } if (stock.F_Number - bodyinfo.F_ReturnNum < 0) { return("产品数量发生了变化,请重新选择审核退回"); } //判断库存数量是否足够 if (stock.F_Number >= bodyinfo.F_ReturnNum) { //扣减库存 hash = new Hashtable(); hash.Add("F_Number", stock.F_Number - bodyinfo.F_ReturnNum); Sys_Stock.Instance.Update(stock.F_Id, hash, dbtran.Transaction); //标记为已退货 //hash = new Hashtable(); //hash.Add("F_DocumentNum", 1); //PI_Head.Instance.Update(pih.F_Id, hash, dbtran.Transaction); //添加履历 Sys_InReturnHistoryInfo inRec = new Sys_InReturnHistoryInfo(); inRec.F_Id = Guid.NewGuid().ToString(); inRec.F_EnCode = bodyinfo.F_OrderNo; inRec.F_Batch = bodyinfo.F_SerialNum; inRec.F_Vendor = bodyinfo.F_Vendor; inRec.F_VendorName = bodyinfo.F_VendorName; inRec.F_Verify = user; inRec.F_Maker = hinfo.F_Maker; inRec.F_Contacts = hinfo.F_Contacts; inRec.F_TelePhone = hinfo.F_TelePhone; inRec.F_Address = hinfo.F_Address; inRec.F_VeriDate = DateTime.Now; inRec.F_WarehouseId = bodyinfo.F_WarehouseId; inRec.F_WarehouseName = bodyinfo.F_WarehouseName; inRec.F_GoodsName = bodyinfo.F_GoodsName; inRec.F_GoodsId = bodyinfo.F_GoodsId; inRec.F_CargoPositionId = bodyinfo.F_CargoPositionId; inRec.F_CargoPositionName = bodyinfo.F_CargoPositionName; inRec.F_SpecifModel = bodyinfo.F_SpecifModel; inRec.F_SellingPrice = bodyinfo.F_SellingPrice; inRec.F_PurchasePrice = bodyinfo.F_PurchasePrice; inRec.F_Unit = bodyinfo.F_Unit; inRec.F_InStockNum = bodyinfo.F_InStockNum; inRec.F_ReturnNum = bodyinfo.F_ReturnNum; inRec.F_CreatorTime = DateTime.Now; Sys_InReturnHistory.Instance.Insert(inRec, dbtran.Transaction); //添加库存履历 Sys_StockHistoryInfo instockHistory = new Sys_StockHistoryInfo(); instockHistory.F_Id = Guid.NewGuid().ToString(); instockHistory.F_EnCode = bodyinfo.F_OrderNo; instockHistory.F_Batch = bodyinfo.F_SerialNum; instockHistory.F_Vendor = hinfo.F_Vendor; instockHistory.F_VendorName = bodyinfo.F_VendorName; instockHistory.F_Verify = user; instockHistory.F_Maker = hinfo.F_Maker; instockHistory.F_Contacts = hinfo.F_Contacts; instockHistory.F_TelePhone = hinfo.F_TelePhone; instockHistory.F_Address = hinfo.F_Address; instockHistory.F_VeriDate = DateTime.Now; instockHistory.F_WarehouseId = bodyinfo.F_WarehouseId; instockHistory.F_WarehouseName = bodyinfo.F_WarehouseName; instockHistory.F_BllCategory = "入库退货"; instockHistory.F_GoodsName = bodyinfo.F_GoodsName; instockHistory.F_GoodsId = bodyinfo.F_GoodsId; instockHistory.F_CargoPositionId = bodyinfo.F_CargoPositionId; instockHistory.F_CargoPositionName = bodyinfo.F_CargoPositionName; instockHistory.F_SpecifModel = bodyinfo.F_SpecifModel; instockHistory.F_Unit = bodyinfo.F_Unit; instockHistory.F_OperationNum = 0 - bodyinfo.F_ReturnNum; instockHistory.F_CreatorTime = DateTime.Now; Sys_StockHistory.Instance.Insert(instockHistory, dbtran.Transaction); //更新主表入库状态 hash = new Hashtable(); hash.Add("F_State", 1); PI_ReturnHead.Instance.Update(bodyinfo.F_HId, hash, dbtran.Transaction); } else { return(bodyinfo.F_WarehouseName + "仓库库存不足,产品:" + bodyinfo.F_GoodsName + "库存为:" + stock.F_Number); } //更新审核状态 string sql = string.Format("update PI_ReturnHead set F_Status=1,F_VeriDate='{0}',F_Verify='{1}' where F_Id='{2}'", date, user, Id); hash = new Hashtable(); base.ExecuteNonQuery(sql, hash, dbtran.Transaction); } dbtran.Commit(); return("单据审核成功"); } catch (Exception ex) { dbtran.RollBack(); return("操作失败"); throw ex; } } } }
public async Task <KgmApiResultEntity> SaveTempScan([FromBody] SaveTempScanModel dto) { string[] str = dto.Barcode.Split('|'); KgmApiResultEntity result = new KgmApiResultEntity(); SearchCondition search = new SearchCondition(); search.AddCondition("F_EnCode", dto.Warehouse, SqlOperator.Equal); var warehouse = BLLFactory <Mst_Warehouse> .Instance.FindSingle(search.BuildConditionSql().Replace("Where", string.Empty)); if (warehouse == null) { result.result = false; result.message = "仓库编码错误"; return(result); } ; dto.Warehouse = warehouse.F_Id; search = new SearchCondition(); search.AddCondition("F_EnCode", str[0], SqlOperator.Equal); search = new SearchCondition(); search.AddCondition("F_EnCode", dto.Position, SqlOperator.Equal); var position = BLLFactory <Mst_CargoPosition> .Instance.FindSingle(search.BuildConditionSql().Replace("Where", string.Empty)); if (position == null) { result.result = false; result.message = "货位编码错误"; return(result); } dto.Position = position.F_Id; if (!String.IsNullOrEmpty(dto.DesPosition)) { search = new SearchCondition(); search.AddCondition("F_EnCode", dto.DesPosition, SqlOperator.Equal); var DesPosition = BLLFactory <Mst_CargoPosition> .Instance.FindSingle(search.BuildConditionSql().Replace("Where", string.Empty)); if (DesPosition == null) { result.result = false; result.message = "目标仓库编码错误"; return(result); } } if (!string.IsNullOrEmpty(dto.DesWarehouse)) { search = new SearchCondition(); search.AddCondition("F_EnCode", dto.DesWarehouse, SqlOperator.Equal); var DesWarehouse = BLLFactory <Mst_CargoPosition> .Instance.FindSingle(search.BuildConditionSql().Replace("Where", string.Empty)); if (DesWarehouse == null) { result.result = false; result.message = "目标货位编码错误"; return(result); } } result.result = true; return(await Task.Run(() => { var dt = BLLFactory <AppCommon> .Instance.SaveTempScan(dto); if (!string.IsNullOrEmpty(dt.Rows[0][0].ToString())) { result.result = false; } result.message = result.result == true ? "操作成功" : dt.Rows[0][0].ToString(); if (dto.DeleteMark) { result.message = result.result == true ? "删除成功" : dt.Rows[0][0].ToString(); } return result; })); }
/// <summary> /// 删除子表信息 /// </summary> /// <param name="keyValue"></param> public void deleteId(string keyValue) { using (DbTransactionScope <SYS_BarcodeSettingDetailInfo> dbtran = base.CreateTransactionScope()) { try { SearchCondition condition = new SearchCondition(); condition.AddCondition("F_Id", keyValue, SqlOperator.Equal); BLLFactory <SYS_BarcodeSettingDetail> .Instance.DeleteByCondition(condition.BuildConditionSql().Replace("Where (1=1) AND ", string.Empty), dbtran.Transaction); dbtran.Commit(); } catch (Exception ex) { dbtran.RollBack(); throw ex; } } }
/// <summary> /// 准备数据内容 /// </summary> /// <returns></returns> private DataTable CreateData() { DataTable dt = new DataTable(); dt.Columns.Add(new DataColumn("类型")); List <int> totalInList = new List <int>(); List <int> totalOutList = new List <int>(); for (int i = 1; i <= 12; i++) { dt.Columns.Add(new DataColumn(string.Format("{0}-{1}月", this.txtYear.Text, i), typeof(decimal))); DateTime dtStart = Convert.ToDateTime(string.Format("{0}-{1}-1", this.txtYear.Text, i)); DateTime dtEnd = dtStart.AddMonths(1); SearchCondition condition = new SearchCondition(); condition.AddCondition("h.WareHouse", this.txtWareHouse.Text, SqlOperator.Like);//增加h为指定特定的表 condition.AddCondition("CreateDate", dtStart, SqlOperator.MoreThanOrEqual); condition.AddCondition("CreateDate", dtEnd, SqlOperator.LessThan); //入库数量 int totalIn = BLLFactory <PurchaseHeader> .Instance.GetPurchaseQuantity(condition.BuildConditionSql().Replace("Where", ""), true); totalInList.Add(totalIn); condition = new SearchCondition(); condition.AddCondition("h.WareHouse", this.txtWareHouse.Text, SqlOperator.Like);//增加h为指定特定的表 condition.AddCondition("CreateDate", dtStart, SqlOperator.MoreThanOrEqual); condition.AddCondition("CreateDate", dtEnd, SqlOperator.LessThan); //出库数量 int totalOut = BLLFactory <PurchaseHeader> .Instance.GetPurchaseQuantity(condition.BuildConditionSql().Replace("Where", ""), false); totalOutList.Add(totalOut); } DataRow dr = dt.NewRow(); dr[0] = "入库数量"; int j = 1; foreach (int count in totalInList) { dr[j++] = count; } dt.Rows.Add(dr); dr = dt.NewRow(); dr[0] = "出库数量"; j = 1; foreach (int count in totalOutList) { dr[j++] = count; } dt.Rows.Add(dr); return(dt); }