public int UpArrivaleNoticeStatus(ArrivalNotice query) { try { return _IArrivalNoticeDao.UpArrivaleNoticeStatus(query); } catch (Exception ex) { throw new Exception("ArrivalNoticeMgr-->UpArrivaleNoticeStatus-->" + ex.Message, ex); } }
public int SaveArrivaleNotice(ArrivalNotice query) { try { return _IArrivalNoticeDao.SaveArrivaleNotice(query); } catch (Exception ex) { throw new Exception("ArrivalNoticeMgr-->SaveArrivaleNotice-->" +ex.Message, ex); } }
public HttpResponseBase SaveArrivaleNotice() { ArrivalNotice arr = new ArrivalNotice(); string jsonStr = String.Empty; try { if (!string.IsNullOrEmpty(Request.Params["id"])) { arr.id=uint.Parse(Request.Params["id"]); } if (!string.IsNullOrEmpty(Request.Params["product_id"])) { arr.product_id = uint.Parse(Request.Params["product_id"]); } if (!string.IsNullOrEmpty(Request.Params["item_id"])) { arr.item_id = uint.Parse(Request.Params["item_id"]); } if (!string.IsNullOrEmpty(Request.Params["user_id"])) { arr.user_id = uint.Parse(Request.Params["user_id"]); } arr.source_type = 2; arr.status = 0; arr.send_notice_time = 0; arr.create_time = uint.Parse(CommonFunction.GetPHPTime().ToString()); arr.muser_id = (Session["caller"] as Caller).user_id; _arrivalMgr = new ArrivalNoticeMgr(mySqlConnectionString); if (arr.id == 0)//新增 { int result=_arrivalMgr.SaveArrivaleNotice(arr); if (result == 1) { jsonStr = "{success:true,msg:\"" + 1 + "\"}"; } if (result == 98) { jsonStr = "{success:true,msg:\"" + 98 + "\"}";//此人員已在未通知列表中 } else { jsonStr = "{success:true,msg:\"" + 99 + "\"}"; } } else //修改 { int result = _arrivalMgr.UpArrivaleNoticeStatus(arr); if (result==100) { jsonStr = "{success:true,msg:\"" + 100 + "\"}"; //jsonStr = "{success:true,msg:\"此此人不在補貨通知以內貨已取消通知!\"}"; } else { jsonStr = "{success:true,msg:\"" + 99 + "\"}"; } } } catch (Exception ex) { Log4NetCustom.LogMessage logMessage = new Log4NetCustom.LogMessage(); logMessage.Content = string.Format("TargetSite:{0},Source:{1},Message:{2}", ex.TargetSite.Name, ex.Source, ex.Message); logMessage.MethodName = System.Reflection.MethodBase.GetCurrentMethod().Name; log.Error(logMessage); jsonStr = "{success:false}"; } this.Response.Clear(); this.Response.Write(jsonStr.ToString()); this.Response.End(); return this.Response; }
public int UpArrivaleNoticeStatus(ArrivalNotice query) { StringBuilder sql = new StringBuilder(); try { sql.AppendFormat(" select count(id) as Total from arrival_notice where item_id='{0}' and user_id='{1}' and status='0'; ", query.item_id, query.user_id); DataTable _td = _access.getDataTable(sql.ToString()); sql.Clear(); if (Convert.ToInt32(_td.Rows[0]["Total"]) > 0) { sql.AppendFormat(" set sql_safe_updates = 0;UPDATE arrival_notice SET status='2' where item_id='{0}' and user_id='{1}'; set sql_safe_updates = 1; ", query.item_id, query.user_id); return _access.execCommand(sql.ToString()); } else { return 100; } } catch (Exception ex) { throw new Exception("ArrivalNoticeDao-->UpArrivaleNoticeStatus-->" + ex.Message + sql.ToString(), ex); } }
public int SaveArrivaleNotice(ArrivalNotice query) { StringBuilder sql = new StringBuilder(); int result = 1; try { sql.AppendFormat(" select Count(user_id) as Total from arrival_notice where user_id='{0}' and item_id='{1}' and status=0;", query.user_id, query.item_id); DataTable _dtUser = _access.getDataTable(sql.ToString()); sql.Clear(); if (Convert.ToInt32(_dtUser.Rows[0]["Total"]) > 0) { result = 98;//此人員已在未通知列表中 } else { sql.AppendFormat("INSERT INTO arrival_notice(user_id,item_id,product_id,status,create_time,source_type,muser_id,send_notice_time)value("); sql.AppendFormat("'{0}','{1}','{2}','{3}','{4}','{5}' ", query.user_id, query.item_id, query.product_id, query.status, query.create_time, query.source_type); sql.AppendFormat(",'{0}','{1}'); ", query.muser_id, query.send_notice_time); _access.execCommand(sql.ToString()); result = 99; } return result; } catch (Exception ex) { throw new Exception("ArrivalNoticeDao-->SaveArrivaleNotice-->" + ex.Message + sql.ToString(), ex); } }
public bool Start(string schedule_code) { bool result = false; try { if (string.IsNullOrEmpty(schedule_code)) { return result; } productItemMgr = new ProductItemMgr(mySqlConnectionString); _paraMgr = new ParameterMgr(mySqlConnectionString); ProductItemQuery query = new ProductItemQuery(); ArrivalNotice arriva = new ArrivalNotice(); MailModel mailModel = new MailModel(); mailModel.MysqlConnectionString = mySqlConnectionString; string GroupCode = string.Empty; string MailTitle = string.Empty; string MailBody = string.Empty; string NOSuggestCountMsg = "今天沒有要採購的商品";//沒有要採購的商品提示 string sumDays = "60";//採購總天數 string periodDays = "1";//採購週期天數 ScheduleServiceMgr _secheduleServiceMgr; //獲取該排程參數 List<ScheduleConfigQuery> store_config = new List<ScheduleConfigQuery>(); ScheduleConfigQuery query_config = new ScheduleConfigQuery(); query_config.schedule_code = schedule_code; _secheduleServiceMgr = new ScheduleServiceMgr(mySqlConnectionString); store_config = _secheduleServiceMgr.GetScheduleConfig(query_config); #region FTP參數賦值 foreach (ScheduleConfigQuery item in store_config) { if (item.parameterCode.Equals("MailFromAddress")) { mailModel.MailFromAddress = item.value; } else if (item.parameterCode.Equals("MailHost")) { mailModel.MailHost = item.value; } else if (item.parameterCode.Equals("MailPort")) { mailModel.MailPort = item.value; } else if (item.parameterCode.Equals("MailFromUser")) { mailModel.MailFromUser = item.value; } else if (item.parameterCode.Equals("EmailPassWord")) { mailModel.MailFormPwd = item.value; } else if (item.parameterCode.Equals("GroupCode")) { GroupCode = item.value; } else if (item.parameterCode.Equals("MailTitle")) { MailTitle = item.value; } else if (item.parameterCode.Equals("MailTitle")) { MailTitle = item.value; } else if (item.parameterCode.Equals("MailBody")) { MailBody = item.value; } else if (item.parameterCode.Equals("sumDays")) { sumDays = item.value; } else if (item.parameterCode.Equals("periodDays")) { periodDays = item.value; } else if (item.parameterCode.Equals("NOSuggestCountMsg")) { NOSuggestCountMsg = item.value; } } #endregion Parametersrc p = new Parametersrc(); List<Parametersrc> list = new List<Parametersrc>(); p.ParameterType = "Food_Articles"; list = _paraMgr.GetAllKindType(p.ParameterType); for (int i = 0; i < list.Count; i++)/*要禁用的食品錧和用品館的商品*/ { if (!string.IsNullOrEmpty(list[i].ParameterCode)) { query.category_ID_IN += list[i].ParameterCode + ","; } } query.sumDays = int.Parse(sumDays); query.periodDays = int.Parse(periodDays); query.category_ID_IN = query.category_ID_IN.TrimEnd(','); query.sale_status = 100; query.Is_pod = 0; query.stockScope = 2; query.prepaid = -1; query.IsPage = false; int totalCount = 0; DataTable dt = productItemMgr.GetSuggestPurchaseInfo(query, out totalCount); MailHelper mail = new MailHelper(mailModel); if (dt.Rows.Count > 0) { DataTable dtExcel = new DataTable(); dtExcel.Columns.Add("行號", typeof(String)); dtExcel.Columns.Add("供應商編號", typeof(String)); dtExcel.Columns.Add("供應商名稱", typeof(String));// dtExcel.Columns.Add("商品編號", typeof(String)); dtExcel.Columns.Add("商品細項編號", typeof(String)); dtExcel.Columns.Add("商品ERP編號", typeof(String)); dtExcel.Columns.Add("商品名稱", typeof(String)); //dtExcel.Columns.Add("商品狀態", typeof(String)); //dtExcel.Columns.Add("販售狀態", typeof(String)); dtExcel.Columns.Add("規格", typeof(String)); // dtExcel.Columns.Add("規格二", typeof(String)); dtExcel.Columns.Add("庫存量", typeof(String)); dtExcel.Columns.Add("後台庫存量", typeof(String)); dtExcel.Columns.Add("安全存量", typeof(String)); dtExcel.Columns.Add("建議採購量", typeof(String));//ipo_qty dtExcel.Columns.Add("未驗收數量", typeof(String)); dtExcel.Columns.Add("補貨通知人數", typeof(String)); dtExcel.Columns.Add("成本", typeof(String)); dtExcel.Columns.Add("價格", typeof(String)); dtExcel.Columns.Add("上架時間", typeof(String)); dtExcel.Columns.Add("下架時間", typeof(String)); for (int i = 0; i < dt.Rows.Count; i++) { #region DataRow newRow = dtExcel.NewRow(); newRow[0] = i + 1; newRow[1] = Convert.ToInt64(dt.Rows[i]["vendor_id"]); newRow[2] = dt.Rows[i]["vendor_name_full"]; newRow[3] = dt.Rows[i]["product_id"]; newRow[4] = dt.Rows[i]["item_id"]; newRow[5] = dt.Rows[i]["erp_id"]; newRow[6] = dt.Rows[i]["product_name"]; //newRow[7] = dt.Rows[i]["product_status_string"]; //newRow[8] = dt.Rows[i]["sale_name"]; newRow[7] = dt.Rows[i]["spec_title_1"]; newRow[8] = dt.Rows[i]["item_stock"]; newRow[9] = dt.Rows[i]["iinvd_stock"]; newRow[10] = dt.Rows[i]["item_alarm"]; if (string.IsNullOrEmpty(dt.Rows[i]["sum_total"].ToString())) { newRow[11] = 0; } #region else { double sum_total = 0; int safe_stock_amount = 0; int item_stock = 0; int item_alarm = 0; int procurement_days = 0; if (double.TryParse(dt.Rows[i]["sum_total"].ToString(), out sum_total)) { sum_total = Convert.ToDouble(dt.Rows[i]["sum_total"]); } if (int.TryParse(dt.Rows[i]["safe_stock_amount"].ToString(), out safe_stock_amount)) { safe_stock_amount = Convert.ToInt32(dt.Rows[i]["safe_stock_amount"]); } if (int.TryParse(dt.Rows[i]["item_stock"].ToString(), out item_stock)) { item_stock = Convert.ToInt32(dt.Rows[i]["item_stock"]); } if (int.TryParse(dt.Rows[i]["item_alarm"].ToString(), out item_alarm)) { item_alarm = Convert.ToInt32(dt.Rows[i]["item_alarm"]); } if (int.TryParse(dt.Rows[i]["procurement_days"].ToString(), out procurement_days)) { procurement_days = Convert.ToInt32(dt.Rows[i]["procurement_days"]); } if (item_stock - procurement_days * sum_total / query.sumDays * query.periodDays <= item_alarm) { //建議採購量:供應商的進貨天數*採購調整系數*近3個月的平均每周銷售數量(最小值為1) double suggestPurchaseTemp = (procurement_days + safe_stock_amount) * (sum_total / query.sumDays) * query.periodDays + ((item_alarm - item_stock) > 0 ? (item_alarm - item_stock) : 0); if (suggestPurchaseTemp <= int.Parse(dt.Rows[i]["min_purchase_amount"].ToString())) //最小值為1 { newRow[11] = dt.Rows[i]["min_purchase_amount"]; } else { int suggestPurchase = Convert.ToInt32(suggestPurchaseTemp); if (suggestPurchase < suggestPurchaseTemp) { newRow[11] = Convert.ToInt32(suggestPurchaseTemp) + 1; } else { newRow[11] = Convert.ToInt32(suggestPurchaseTemp); } } } } #endregion newRow[12] = dt.Rows[i]["ipo_qty"]; newRow[13] = dt.Rows[i]["NoticeGoods"]; newRow[14] = dt.Rows[i]["item_cost"]; newRow[15] = dt.Rows[i]["item_money"]; newRow[16] = string.IsNullOrEmpty(dt.Rows[i]["product_start"].ToString()) ? " " : DateTime.Parse(dt.Rows[i]["product_start"].ToString()).ToString("yyyy-MM-dd hh:mm:ss"); newRow[17] = string.IsNullOrEmpty(dt.Rows[i]["product_end"].ToString()) ? "" : DateTime.Parse(dt.Rows[i]["product_end"].ToString()).ToString("yyyy-MM-dd hh:mm:ss"); dtExcel.Rows.Add(newRow); #endregion } string EmailContent = GetMail(dtExcel); mail.SendToGroup(GroupCode, MailTitle, EmailContent, false, true);//發送郵件給群組 } else { mail.SendToGroup(GroupCode, MailTitle, NOSuggestCountMsg, false, true);//發送郵件給群組 } result = true; } catch (Exception ex) { throw new Exception("SendOrderInfoToBlackCatFTPMgr-->Start-->" + ex.Message); } return result; }