public List<Parametersrc> Query(Parametersrc para) { para.Replace4MySQL(); StringBuilder strSql = new StringBuilder("select rowid,parametertype,parameterproperty,parametercode,parametername,remark,kdate,kuser,used,sort,topvalue from t_parametersrc where 1=1 "); try { if (para.Rowid != 0) { strSql.AppendFormat(" and rowid='{0}' ", para.Rowid); } if (!string.IsNullOrEmpty(para.ParameterType)) { strSql.AppendFormat(" and parametertype='{0}' ", para.ParameterType); } if (!string.IsNullOrEmpty(para.ParameterCode)) { strSql.AppendFormat(" and parametercode='{0}' ", para.ParameterCode); } if (!string.IsNullOrEmpty(para.parameterName)) { strSql.AppendFormat(" and parametername='{0}' ", para.parameterName); } if (!string.IsNullOrEmpty(para.TopValue)) { strSql.AppendFormat(" and topvalue = '{0}'", para.TopValue); } strSql.AppendFormat(" and used='{0}' ", para.Used); return _accessMySql.getDataTableForObj<Parametersrc>(strSql.ToString()); } catch (Exception ex) { throw new Exception("ParametersrcDap-->Query"+ex.Message+strSql.ToString(),ex); } }
public void OutExcel() { List<Parametersrc> store = new List<Parametersrc>(); model = new PayEasyQuery(); psmodel = new Parametersrc(); _payeasemgr = new PayEasyMgr(mySqlConnectionString); try { try { model.rid = Convert.ToInt32(Request.Params["product_id"] ?? "0"); } catch (Exception) { model.rid = 0; } psmodel.ParameterType = "payeasy"; psmodel.ParameterCode = "1"; store = _parameter.QueryUsed(psmodel); foreach (var item in store) { model.chnanel_id = Int32.Parse(item.ParameterProperty); } psmodel.ParameterCode = "2"; store = _parameter.QueryUsed(psmodel); foreach (var item in store) { model.category_id = Int32.Parse(item.ParameterProperty); } //MemoryStream ms = ExcelHelperXhf.ExportDT(_payeasemgr.QueryExcel(model), "匯出"); //Response.AddHeader("Content-Disposition", string.Format("attachment; filename={0}.csv", DateTime.Now.ToString("yyyyMMddhhmmss"))); //Response.BinaryWrite(ms.ToArray()); //ms.Close(); //ms.Dispose(); string fileName = DateTime.Now.ToString("6727_yyyyMMddHHmm") + ".xls"; MemoryStream ms = ExcelHelperXhf.ExportDT(_payeasemgr.QueryExcel(model), ""); Response.AddHeader("Content-Disposition", "attachment; filename=" + Server.UrlEncode(fileName)); Response.BinaryWrite(ms.ToArray()); //StringWriter sw = ExcelHelperXhf.SetCsvFromData(_payeasemgr.QueryExcel(model), fileName); //Response.Clear(); //Response.AddHeader("Content-Disposition", "attachment; filename=" + Server.UrlEncode(fileName)); //Response.ContentType = "application/ms-excel"; //Response.ContentEncoding = Encoding.Default; //Response.Write(sw); //Response.End(); } 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); } }
/// <summary> /// 獲取參數 /// </summary> /// <param name="para"></param> /// <returns></returns> public List<Parametersrc> QueryPara(Parametersrc para) { try { StringBuilder sb = new StringBuilder(); sb.AppendFormat(" SELECT parameterName,parameterCode from t_parametersrc WHERE parameterType='{0}';", para.ParameterType); return _accessMySql.getDataTableForObj<Parametersrc>(sb.ToString()); } catch (Exception ex) { throw new Exception("PageErrorLogDao.QueryPara-->" + ex.Message + ex); } }
public string Save(Parametersrc p) { StringBuilder stb = new StringBuilder("insert into t_parametersrc (parametertype,parameterproperty,parametercode,parametername,remark,kdate,kuser,used,sort,topvalue) values "); try { stb.AppendFormat("('{0}','{1}','{2}','{3}','{4}',now(),'{5}','{6}','{7}','{8}')", p.ParameterType, p.ParameterProperty, p.ParameterCode, p.parameterName, p.remark, p.Kuser, p.Used, p.Sort, p.TopValue); return stb.ToString(); } catch (Exception ex) { throw new Exception("ParametersrcDap-->Save" + ex.Message + stb.ToString(), ex); } }
public List<Parametersrc> QueryForTopValue(Parametersrc para) { para.Replace4MySQL(); StringBuilder strSql = new StringBuilder("select rowid,parametertype,parameterproperty,parametercode,parametername,remark,kdate,kuser,used,sort,topvalue"); try { strSql.AppendFormat(" from t_parametersrc where 1=1 and topvalue = '{0}' and parametertype='{1}' ", para.TopValue, para.ParameterType); strSql.AppendFormat(" and used={0}", para.Used); return _accessMySql.getDataTableForObj<Parametersrc>(strSql.ToString()); } catch (Exception ex) { throw new Exception("ParametersrcDap-->QueryForTopValue" + ex.Message + strSql.ToString(), ex); } }
public int Delete(Parametersrc m) { int i = 0; MySqlCommand mySqlCmd = new MySqlCommand(); MySqlConnection mySqlConn = new MySqlConnection(connStr); StringBuilder sb = new StringBuilder(); try { if (mySqlConn != null && mySqlConn.State == System.Data.ConnectionState.Closed) { mySqlConn.Open(); } mySqlCmd.Connection = mySqlConn; mySqlCmd.Transaction = mySqlConn.BeginTransaction(); mySqlCmd.CommandType = System.Data.CommandType.Text; PromoPair pp = new PromoPair(); if (m.Rowid != 0) { sb.AppendFormat("Delete from t_parametersrc where Rowid ='{0}';", m.Rowid); } mySqlCmd.CommandText = sb.ToString(); i += mySqlCmd.ExecuteNonQuery(); mySqlCmd.Transaction.Commit(); } catch (Exception ex) { mySqlCmd.Transaction.Rollback(); throw new Exception("PromoPair-->Delete-->" + ex.Message +",sql:"+ sb.ToString(), ex); } finally { if (mySqlConn != null && mySqlConn.State == System.Data.ConnectionState.Open) { mySqlConn.Close(); } } return i; }
public List<Parametersrc> GetIialgParametersrcList(Parametersrc store, out int totalCount) { store.Replace4MySQL(); StringBuilder sqlcount = new StringBuilder(); StringBuilder sqlfrom = new StringBuilder(); StringBuilder strSql = new StringBuilder("select t.rowid,t.parametertype,t.parameterproperty,t.parametercode,t.parametername,t.remark,t.kdate,t.kuser,t.used,t.sort,tp.parameterName as 'TopValue' "); sqlfrom.AppendFormat(" FROM t_parametersrc t LEFT JOIN t_parametersrc tp ON t.topValue = tp.rowid where 1=1 and tp.parameterType='wms_parameter' ");//parameterType='wms_parameter' sqlcount.AppendFormat(@" select count(*) as searchtotal "); //if (store.Rowid != 0) //{ // sqlfrom.AppendFormat(" and rowid='{0}' ", store.Rowid); //} if (!string.IsNullOrEmpty(store.remark))//這裡remark做為搜獲的內容 { sqlfrom.AppendFormat(" and (t.parameterType like'%{0}%' or t.parameterName like '%{0}%') ", store.remark); } sqlfrom.AppendFormat(" order by t.rowid desc "); totalCount = 0; if (store.IsPage) { DataTable _dt = _accessMySql.getDataTable(sqlcount.ToString() + sqlfrom.ToString()); if (_dt != null && _dt.Rows.Count > 0) { totalCount = Convert.ToInt32(_dt.Rows[0]["searchtotal"]); } sqlfrom.AppendFormat(" limit {0},{1}", store.Start, store.Limit); } try { return _accessMySql.getDataTableForObj<Parametersrc>(strSql.ToString() + sqlfrom.ToString()); } catch (Exception ex) { throw new Exception(" ParametersrcDao-->GetIialgParametersrcList-->" + strSql.ToString() + sqlfrom.ToString() + ex.Message, ex); } }
public List<Parametersrc> GetIialgParametersrcList(Parametersrc store, out int totalCount) { try { return _paraDao.GetIialgParametersrcList(store, out totalCount); } catch (Exception ex) { throw new Exception(" ParameterMgr-->GetIialgParametersrcList-->" + ex.Message, ex); } }
//取參數表數據 public DataTable GetTP(string type) { string json = string.Empty; Parametersrc p = new Parametersrc(); DataTable dt = new DataTable(); _ptersrc = new ParameterMgr(mySqlConnectionString); try { p.ParameterType = type; dt = _ptersrc.GetTP(p); if (dt.Rows.Count > 0) { return dt; } else { return null; } } 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); return null; } }
/// <summary> /// 列表頁帶參數值優化 /// </summary> /// <param name="p"></param> /// <returns></returns> public DataTable GetTP(Parametersrc p) { StringBuilder sb = new StringBuilder(); try { sb.AppendFormat("select rowid,ParameterName,parameterCode,remark from t_parametersrc where 1=1 "); if (!String.IsNullOrEmpty(p.ParameterType)) { sb.AppendFormat(" AND ParameterType='{0}' ", p.ParameterType); } if (!String.IsNullOrEmpty(p.parameterName)) { if (p.parameterName == "自取") { sb.AppendFormat(" AND parameterName like '{0}%' ", p.parameterName); } else { sb.AppendFormat(" AND parameterName='{0}' ", p.parameterName); } } if (!String.IsNullOrEmpty(p.TopValue)) { sb.AppendFormat(" AND TopValue='{0}' ", p.TopValue); } if (!String.IsNullOrEmpty(p.ParameterCode)) { sb.AppendFormat(" AND ParameterCode='{0}' ", p.ParameterCode); } sb.Append(" ORDER BY rowid DESC;"); return _accessMySql.getDataTable(sb.ToString()); } catch (Exception ex) { throw new Exception(" ParametersrcDao-->GetTP-->" + ex.Message + ",sql:" + sb.ToString(), ex); } }
public string DeleteByType(Parametersrc p) { return string.Format("set sql_safe_updates = 0; delete from t_parametersrc where parametertype = '{0}';set sql_safe_updates = 1;", p.ParameterType); }
public string Update(Parametersrc p) { StringBuilder stb = new StringBuilder("set sql_safe_updates = 0;update t_parametersrc set"); try { stb.AppendFormat(" parametertype = '{0}',parameterproperty='{1}',parametercode = '{2}',parametername='{3}',remark='{4}',kuser='******',used='{7}',sort='{8}',topvalue='{9}'", p.ParameterType, p.ParameterProperty, p.ParameterCode, p.parameterName, p.remark, p.Kdate, p.Kuser, p.Used, p.Sort, p.TopValue); stb.AppendFormat(" where rowid = {0};set sql_safe_updates = 1;", p.Rowid); return stb.ToString(); } catch (Exception ex) { throw new Exception("ParametersrcDao-->Update" + ex.Message + stb.ToString(), ex); } }
/// <summary> /// 獲取編輯頁面的combobox的數據 /// </summary> /// <param name="pt">搜索條件</param> /// <param name="name">搜索條件</param> /// <returns></returns> public System.Data.DataTable GetLogisticsName(Parametersrc pt, string name) { StringBuilder sb = new StringBuilder(); try { sb.AppendFormat(@"SELECT tp.parameterCode,tp.parameterName FROM t_parametersrc tp WHERE tp.parameterType='{0}' ", pt.ParameterType); if (!string.IsNullOrEmpty(name)) { sb.AppendFormat(" and tp.parameterCode like '{0}" + "%" + "'", name); } return _dbAccess.getDataTable(sb.ToString()); } catch (Exception ex) { throw new Exception("ShippingCarriorDao-->GetLogisticsName-->" + ex.Message + "sql:" + sb.ToString(), ex); } }
public DataTable GetTP(Parametersrc p) { try { return _paraDao.GetTP(p); } catch (Exception ex) { throw new Exception(" ParameterMgr-->GetTP-->" + ex.Message, ex); } }
public int UpdTP(Parametersrc p) { try { return _paraDao.UpdTP(p); } catch (Exception ex) { throw new Exception(" ParameterMgr-->UpdTP-->" + ex.Message, ex); } }
public List<Parametersrc> GetParameter(Parametersrc p) { try { return _paraDao.GetParameter(p); } catch (Exception ex) { throw new Exception(" ParameterMgr-->GetParameter-->" + ex.Message, ex); } }
public int Delete(Parametersrc m) { try { return _paraDao.Delete(m); } catch (Exception ex) { throw new Exception(" ParameterMgr-->Delete-->" + ex.Message, ex); } }
public List<Parametersrc> GetParameter(Parametersrc p) { StringBuilder sb = new StringBuilder(); try { sb.AppendFormat("select rowid,parametername from t_parametersrc where 1=1 "); if (!String.IsNullOrEmpty(p.ParameterType)) { sb.AppendFormat(" AND ParameterType='{0}' ", p.ParameterType); } if (!String.IsNullOrEmpty(p.parameterName)) { sb.AppendFormat(" AND parameterName='{0}' ",p.parameterName); } return _accessMySql.getDataTableForObj<Parametersrc>(sb.ToString()); } catch (Exception ex) { throw new Exception(" ParametersrcDao-->GetParameter-->"+ ex.Message +",sql:" + sb.ToString(), ex); } }
public int InsertTP(Parametersrc p) { StringBuilder sb = new StringBuilder(); try { sb.AppendFormat("Insert into t_parametersrc(parametertype,parametercode,parametername,remark,kdate,kuser,used,sort,TopValue)"); sb.AppendFormat(" VALUES ('{0}','{1}','{2}','{3}',",p.ParameterType,p.ParameterCode,p.parameterName,p.remark); sb.AppendFormat("'{0}','{1}','{2}','{3}','{4}');",CommonFunction.DateTimeToString(p.Kdate),p.Kuser,p.Used,p.Sort,p.TopValue); return _accessMySql.execCommand(sb.ToString()); } catch (Exception ex) { throw new Exception("ParametersrcDao-->InsertTP-->" + ex.Message + ",sql:" + sb.ToString(), ex); } }
//public DataTable QueryPropertySite() //{ // StringBuilder sbsql = new StringBuilder(); // sbsql.Append("select parameterProperty from t_parametersrc where 1=1 "); // if (Cquery.TopValue != "") // { // sbsql.AppendFormat(" and topValue='{0}'", Cquery.TopValue); // } // if (Cquery.ParameterType != "") // { // sbsql.AppendFormat(" and ParameterType='{0}'", Cquery.ParameterType); // } // if (Cquery.ParameterCode != "") // { // sbsql.AppendFormat(" and ParameterCode='{0}'", Cquery.ParameterCode); // } // return _accessMySql.getDataTable(sbsql.ToString()); //} public DataTable QueryProperty(Parametersrc Pquery, Parametersrc Cquery) { StringBuilder str = new StringBuilder(); try { int fathar_id = 0; str.AppendFormat("select * from t_parametersrc where ParameterType='{0}' and ParameterCode='{1}'", Pquery.ParameterType, Pquery.ParameterCode); System.Data.DataTable _dt = _accessMySql.getDataTable(str.ToString()); if (_dt != null && _dt.Rows.Count > 0) { fathar_id = Convert.ToInt32(_dt.Rows[0]["rowid"]); Cquery.TopValue = fathar_id.ToString(); } StringBuilder sbsql = new StringBuilder(); sbsql.Append("select parameterProperty from t_parametersrc where 1=1 "); if (Cquery.TopValue != "") { sbsql.AppendFormat(" and topValue='{0}'", Cquery.TopValue); } if (Cquery.ParameterType != "") { sbsql.AppendFormat(" and ParameterType='{0}'", Cquery.ParameterType); } if (Cquery.ParameterCode != "") { sbsql.AppendFormat(" and ParameterCode='{0}'", Cquery.ParameterCode); } return _accessMySql.getDataTable(sbsql.ToString()); } catch (Exception ex) { throw new Exception("ParametersrcDao-->QueryProperty"+ex.Message + str.ToString(), ex); } }
public int UpdTP(Parametersrc p) { StringBuilder sb = new StringBuilder("set sql_safe_updates = 0;update t_parametersrc set "); sb.AppendFormat(" parametertype='{0}', parametercode = '{1}',parametername='{2}',remark='{3}' ", p.ParameterType, p.ParameterCode, p.parameterName, p.remark); sb.AppendFormat(" where rowid = {0};set sql_safe_updates = 1;", p.Rowid); try { return _accessMySql.execCommand(sb.ToString()); } catch (Exception ex) { throw new Exception(" ParametersrcDao-->UpdTP-->"+ ex.Message + ",sql:" + sb.ToString() , ex); } }
public List<Parametersrc> GetParametersrcList(Parametersrc store, out int totalCount) { store.Replace4MySQL(); StringBuilder sqlcount = new StringBuilder(); StringBuilder sqlfrom = new StringBuilder(); StringBuilder strSql = new StringBuilder("select rowid,parametertype,parameterproperty,parametercode,parametername,remark,kdate,kuser,used,sort,topvalue "); sqlfrom.AppendFormat(" from t_parametersrc where 1=1 "); sqlcount.AppendFormat(@" select count(*) as searchtotal "); if (store.Rowid != 0) { sqlfrom.AppendFormat(" and rowid='{0}' ", store.Rowid); } if (!string.IsNullOrEmpty(store.ParameterType)) { sqlfrom.AppendFormat(" and parameterType like N'%{0}%' ", store.ParameterType); sqlfrom.AppendFormat(" or parameterProperty like N'%{0}%'", store.ParameterType); sqlfrom.AppendFormat(" or parameterCode like N'%{0}%'", store.ParameterType); sqlfrom.AppendFormat(" or parameterName like N'%{0}%'", store.ParameterType); sqlfrom.AppendFormat(" or remark like N'%{0}%'", store.ParameterType); } sqlfrom.AppendFormat(" order by rowid desc "); totalCount = 0; if (store.IsPage) { DataTable _dt = _accessMySql.getDataTable(sqlcount.ToString() + sqlfrom.ToString()); if (_dt != null && _dt.Rows.Count > 0) { totalCount = Convert.ToInt32(_dt.Rows[0]["searchtotal"]); } sqlfrom.AppendFormat(" limit {0},{1}", store.Start, store.Limit); } try { return _accessMySql.getDataTableForObj<Parametersrc>(strSql.ToString() + sqlfrom.ToString()); } catch (Exception ex) { throw new Exception(" ParametersrcDao-->GetParametersrcList-->" + strSql.ToString() + sqlfrom.ToString() + ex.Message, ex); } }
/// <summary> /// 獲取編輯頁面的combobox數據 /// /// </summary> /// <param name="pt">搜索條件</param> /// <param name="name">搜索條件(二級聯動)</param> /// <returns></returns> public System.Data.DataTable GetLogisticsName(Parametersrc pt, string name) { try { return _shippingCarriorDao.GetLogisticsName(pt, name); } catch (Exception ex) { throw new Exception("ShippingCarriorMgr-->GetLogisticsName-->" + ex.Message, ex); } }
public string QueryParameter(Parametersrc p) { string json = string.Empty; try { paraMgr = new ParameterMgr(connectionString); json = paraMgr.QueryBindData(p); } 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); } return json; }
//取參數表自取數據 public HttpResponseBase GetZQ() { string json = "{success:false}"; Parametersrc p = new Parametersrc(); DataTable dt = new DataTable(); _ptersrc = new ParameterMgr(mySqlConnectionString); try { p.ParameterType = "Deliver_Store"; p.parameterName = "自取"; dt = _ptersrc.GetTP(p); if (dt.Rows.Count > 0) { json = "{success:true,data:" + JsonConvert.SerializeObject(dt, Formatting.Indented) + "}";//返回json數據 } } 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); json = "{success:false}"; } this.Response.Clear(); this.Response.Write(json); this.Response.End(); return this.Response; }
public int UpdateUsed(Parametersrc store) { try { return _paraDao.UpdateUsed(store); } catch (Exception ex) { throw new Exception("ParameterMgr-->UpdateUsed-->" + ex.Message, ex); } }
public ActionResult baseInfo() { Parametersrc para = new Parametersrc(); string[] paraList = new string[2] { "", "" }; //加載運費方式 para.ParameterType = "product_freight"; paraList[0] = QueryParameter(para); //加載出貨方式 para.ParameterType = "product_mode"; paraList[1] = QueryParameter(para); return View(paraList); }
/// <summary> /// 參數表新增修改保存方法 /// 2014/10/20號zhejiangj新增 /// </summary> /// <param name="para"></param> /// <returns></returns> public int ParametersrcSave(Parametersrc para) { string strSql = string.Empty; try { if (para.Rowid == 0) { strSql = Save(para); return _accessMySql.execCommand(strSql); } else { strSql = Update(para); return _accessMySql.execCommand(strSql); } } catch (Exception ex) { throw new Exception("ParametersrcDao-->ParametersrcSave-->sql:" + ex.Message + strSql.ToString(), ex); } }
public HttpResponseBase GetNewPromoPresentEventType() { string json=string.Empty; try { string type = "new_promo_present_event_type"; _IParametersrcMgr = new ParameterMgr(mySqlConnectionString); List<Parametersrc> list = _IParametersrcMgr.GetElementType(type); Parametersrc src = new Parametersrc(); src.parameterName = "不分"; src.ParameterCode = "0"; list.Insert(0, src); json = "{data:" + JsonConvert.SerializeObject(list, Formatting.Indented) + "}"; } 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); json = "{success:false,totalCount:0,data:[]}"; } this.Response.Clear(); this.Response.Write(json.ToString()); this.Response.End(); return this.Response; }
public int UpdateUsed(Parametersrc store) { StringBuilder sql = new StringBuilder(); try { sql.AppendFormat(" update t_parametersrc set used='{0}' where rowid='{1}'", store.Used, store.Rowid); return _accessMySql.execCommand(sql.ToString()); } catch (Exception ex) { throw new Exception("ParametersrcDao-->UpdateUsed-->" + sql.ToString() + ex.Message, ex); } }