/// <summary> /// 清除机器数据 /// </summary> /// <returns>结果 True:成功 False:失败</returns> public bool ClearAllData() { bool result = false; // 清除机器销售统计数据 string strSql = "update T_SALE_STAT set [BeginDate] = '',[TotalSaleMoney] = 0 ,[TotalSaleNum] = 0," + "[CycleDate] = '',[CycleSaleMoney] = 0,[CycleSaleNum] = 0," + "[TodayDate] = '',[TodaySaleMoney] = 0,[TodaySaleNum] = 0"; DbOper dbOper = new DbOper(); dbOper.DbFileName = _m_DbFileName; dbOper.ConnType = ConnectType.KeepConn; result = dbOper.excuteSql(strSql); // 清除货币数据 strSql = "update T_MONEY_STAT set [BeginDate] = '',[TotalCashMoney] = 0,[TotalCashNum] = 0,[TotalCoinRecMoney] = 0,[TotalCoinRecNum] = 0," + "[TotalCoinChangeMoney] = 0,[TotalCoinChangeNum] = 0,[CycleDate] = '',[CycleCashMoney] = 0,[CycleCashNum] = 0,[CycleCoinRecMoney] = 0,[CycleCoinRecNum] = 0," + "[CycleCoinChangeMoney] = 0,[CycleCoinChangeNum] = 0,[TodayDate] = '',[TodayCashMoney] = 0,[TodayCashNum] = 0,[TodayCoinRecMoney] = 0,[TodayCoinRecNum] = 0," + "[TodayCoinChangeMoney] = 0,[TodayCoinChangeNum] = 0"; result = dbOper.excuteSql(strSql); dbOper.closeConnection(); // 清除待发的数据 return(result); }
/// <summary> /// 更新某货币面值接收使能/禁能状态 /// </summary> /// <param name="cashValue"></param> /// <param name="stockNum"></param> /// <param name="cashType"></param> /// <returns></returns> public bool UpdateCashStatus_All(int cashValue, string cashType, string status) { bool result = false; string strSql = string.Empty; try { int intListCount = CashInfoList.Count; for (int i = 0; i < intListCount; i++) { if ((CashInfoList[i].CashValue == cashValue) && (CashInfoList[i].CashType == cashType)) { strSql = "update T_VM_CASHINFO set Status = '" + status + "' where CashValue = '" + cashValue + "' and CashType = '" + cashType + "'"; DbOper dbOper = new DbOper(); dbOper.DbFileName = _m_DbFileName; dbOper.ConnType = ConnectType.CloseConn; result = dbOper.excuteSql(strSql); dbOper.closeConnection(); if (result) { CashInfoList[i].Status = status; } break; } } } catch { result = false; } return(result); }
/// <summary> /// 清空商品信息 /// </summary> /// <returns>结果 0:成功 1:失败</returns> public int ClearAllGoods() { bool result = false; int intErrCode = 0; string strSql = string.Empty; DbOper dbOper = new DbOper(); dbOper.DbFileName = _m_DbFileName; dbOper.ConnType = ConnectType.CloseConn; strSql = @"delete from T_MCD_BASEINFO "; result = dbOper.excuteSql(strSql); dbOper.closeConnection(); if (!result) { intErrCode = 1; } else { GoodsList_Total.Clear(); } return(intErrCode); }
/// <summary> /// 清除段销售数据 /// </summary> /// <returns></returns> public bool ClearCycleSaleData() { bool result = false; // 清除销售数据 string strTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); string strDate = DateTime.Now.ToString("yyyyMMdd"); string strSql = @"update T_SALE_STAT set [CycleSaleMoney] = 0,[CycleSaleNum] = 0, [CycleDate] = '" + strTime + "',[TodaySaleMoney] = 0,[TodaySaleNum] = 0,[TodayDate] = '" + strDate + @"'"; DbOper dbOper = new DbOper(); dbOper.DbFileName = _m_DbFileName; dbOper.ConnType = ConnectType.KeepConn; result = dbOper.excuteSql(strSql); // 清除金额数据 strSql = @"update T_MONEY_STAT set [CycleDate] = '" + strTime + @"',[CycleCashMoney] = 0,[CycleCashNum] = 0,[CycleCoinRecMoney] = 0,[CycleCoinRecNum] = 0, [CycleCoinChangeMoney] = 0,[CycleCoinChangeNum] = 0,[TodayDate] = '" + strDate + @"',[TodayCashMoney] = 0,[TodayCashNum] = 0,[TodayCoinRecMoney] = 0,[TodayCoinRecNum] = 0, [TodayCoinChangeMoney] = 0,[TodayCoinChangeNum] = 0"; result = dbOper.excuteSql(strSql); dbOper.closeConnection(); return(result); }
/// <summary> /// 加载商品信息列表—全部 /// </summary> /// <returns>加载结果 True:成功 False:失败</returns> public bool LoadGoodsInfo_Total() { bool result = false; GoodsList_Total.Clear(); DbOper dbOper = new DbOper(); dbOper.DbFileName = _m_DbFileName; try { string strSql = string.Empty; strSql += @"select McdCode,McdName,McdContent,Price, PicName,McdType,IsFree,Manufacturer, GoodsSpec,DrugType,DetailInfo,Unit,McdSaleType from T_MCD_BASEINFO order by id desc"; DataSet dataSet = dbOper.dataSet(strSql); if (dataSet.Tables.Count > 0) { int recordCount = dataSet.Tables[0].Rows.Count; for (int i = 0; i < recordCount; i++) { GoodsList_Total.Add(new GoodsModel() { McdCode = dataSet.Tables[0].Rows[i]["McdCode"].ToString(), McdName = dataSet.Tables[0].Rows[i]["McdName"].ToString(), McdContent = dataSet.Tables[0].Rows[i]["McdContent"].ToString(), PicName = dataSet.Tables[0].Rows[i]["PicName"].ToString(), Price = Convert.ToInt32(dataSet.Tables[0].Rows[i]["Price"].ToString()), IsFree = dataSet.Tables[0].Rows[i]["IsFree"].ToString(), Manufacturer = dataSet.Tables[0].Rows[i]["Manufacturer"].ToString(), GoodsSpec = dataSet.Tables[0].Rows[i]["GoodsSpec"].ToString(), DrugType = dataSet.Tables[0].Rows[i]["DrugType"].ToString(), TypeCode = dataSet.Tables[0].Rows[i]["McdType"].ToString(), Unit = dataSet.Tables[0].Rows[i]["Unit"].ToString(), DetailInfo = dataSet.Tables[0].Rows[i]["DetailInfo"].ToString(), McdSaleType = FunHelper.ChangeMcdSaleType(dataSet.Tables[0].Rows[i]["McdSaleType"].ToString()), }); } } result = true; } catch { result = false; } finally { dbOper.closeConnection(); } return(result); }
/// <summary> /// 根据广告节目单编号读取广告文件 /// </summary> /// <param name="advListID">广告节目单编号</param> /// <returns>结果 True:成功 False:失败</returns> public bool LoadAdvertList_New(string advListID) { bool result = false; AdvertList_Temp.Clear(); DbOper dbOper = new DbOper(); dbOper.DbFileName = _m_DbFileName; try { string strSql = string.Empty; #region 获取广告信息 strSql = @"select FileCode,FileName,FileFormat,FileType,FileSize,PlayNum,DelayTime from T_ADV_ADVFILE where AdvListID ='" + advListID + "' and status = '2'"; DataSet dataSet = dbOper.dataSet(strSql); if (dataSet.Tables.Count > 0) { int recordCount = dataSet.Tables[0].Rows.Count; for (int i = 0; i < recordCount; i++) { AdvertList_Temp.Add(new AdvertInfoModel() { PlayNo = i, FileCode = dataSet.Tables[0].Rows[i]["FileCode"].ToString(), FileName = dataSet.Tables[0].Rows[i]["FileName"].ToString(), FileType = dataSet.Tables[0].Rows[i]["FileFormat"].ToString(), AdvertType = GetAdvertFileType(dataSet.Tables[0].Rows[i]["FileFormat"].ToString()), FileSize = Convert.ToInt32(dataSet.Tables[0].Rows[i]["FileSize"].ToString()), PlayNum = Convert.ToInt32(dataSet.Tables[0].Rows[i]["PlayNum"].ToString()), DelayTime = Convert.ToInt32(dataSet.Tables[0].Rows[i]["DelayTime"].ToString()) }); } } #endregion result = true; } catch { result = false; } finally { dbOper.closeConnection(); AdvertList = AdvertList_Temp; } return(result); }
/// <summary> /// 加载货币信息表 /// </summary> /// <returns>加载结果 True:成功 False:失败</returns> public bool LoadCashInfoList(string countryCode) { bool result = false; CashInfoList.Clear(); DbOper dbOper = new DbOper(); dbOper.DbFileName = _m_DbFileName; try { string strSql = string.Empty; #region 获取货币信息 strSql = @"select CashValue,StockNum,BoxStockNum,CashType,Channel,Status from T_VM_CASHINFO"; DataSet dataSet = dbOper.dataSet(strSql); if (dataSet.Tables.Count > 0) { int recordCount = dataSet.Tables[0].Rows.Count; for (int i = 0; i < recordCount; i++) { CashInfoList.Add(new CashInfoModel() { CashValue = Convert.ToInt32(dataSet.Tables[0].Rows[i]["CashValue"].ToString()), StockNum = Convert.ToInt32(dataSet.Tables[0].Rows[i]["StockNum"].ToString()), BoxStockNum = Convert.ToInt32(dataSet.Tables[0].Rows[i]["BoxStockNum"].ToString()), CashType = dataSet.Tables[0].Rows[i]["CashType"].ToString(), Channel = Convert.ToInt32(dataSet.Tables[0].Rows[i]["Channel"].ToString()), Status = dataSet.Tables[0].Rows[i]["Status"].ToString(), CountryCode = countryCode }); } } #endregion result = true; } catch { result = false; } finally { dbOper.closeConnection(); } return(result); }
/// <summary> /// 删除某商品信息 /// </summary> /// <returns>结果 0:成功 1:已经上架了该商品 其它:失败</returns> public int DeleteGoods(string mcdCode) { bool result = false; int intErrCode = 0; string strSql = string.Empty; try { DbOper dbOper = new DbOper(); dbOper.DbFileName = _m_DbFileName; dbOper.ConnType = ConnectType.CloseConn; // 查询是否有货道已经上架了该商品 strSql = "select McdCode from T_VM_PAINFO where McdCode = '" + mcdCode + "'"; DataSet dataSet = dbOper.dataSet(strSql); if (dataSet.Tables.Count > 0) { if (dataSet.Tables[0].Rows.Count > 0) { // 有货道已经上架了该商品 intErrCode = 1; } } if (intErrCode == 0) { // 删除商品 strSql = @"delete from T_MCD_BASEINFO where mcdcode = '" + mcdCode + "'"; result = dbOper.excuteSql(strSql); if (!result) { intErrCode = 3; } else { LoadGoodsInfo_Total(); } } dbOper.closeConnection(); } catch { intErrCode = 3; } return(intErrCode); }
/// <summary> /// 检测是否有需要下载的广告文件 /// </summary> public void AdvertUploadMon() { DbOper dbOper = new DbOper(); dbOper.DbFileName = _m_DbFileName; try { dbOper.ConnType = ConnectType.KeepConn; string strSql = @"select AdvListID,FileCode,DownUrl,FileName,FileFormat from T_ADV_ADVFILE where ImportType = '1' and Status in ('0','1','3')"; DataSet dataSet = dbOper.dataSet(strSql); if (dataSet.Tables.Count > 0) { int intCount = dataSet.Tables[0].Rows.Count; bool result = false; if (intCount > 0) { AdvertInfoModel advertInfo = new AdvertInfoModel(); for (int i = 0; i < intCount; i++) { advertInfo.AdvListID = dataSet.Tables[0].Rows[i]["AdvListID"].ToString(); advertInfo.FileCode = dataSet.Tables[0].Rows[i]["FileCode"].ToString(); advertInfo.FileName = dataSet.Tables[0].Rows[i]["FileName"].ToString(); advertInfo.DownUrl = dataSet.Tables[0].Rows[i]["DownUrl"].ToString(); advertInfo.FileType = dataSet.Tables[0].Rows[i]["FileFormat"].ToString(); result = DownAdvertFile(advertInfo); if (result) { // 下载成功,保存广告文件状态 strSql = "update T_ADV_ADVFILE set Status = '2' where AdvListID = '" + advertInfo.AdvListID + "' and FileCode = '" + advertInfo.FileCode + "'"; result = dbOper.excuteSql(strSql); } } } } } catch { } finally { dbOper.closeConnection(); } }
public void CheckMcdPicDown() { DbOper dbOper = new DbOper(); dbOper.DbFileName = _m_DbFileName; try { dbOper.ConnType = ConnectType.KeepConn; string strSql = @"select McdCode,McdPic,Url from T_MCD_PICTEMP where Status = '0' limit 1"; DataSet dataSet = dbOper.dataSet(strSql); if (dataSet.Tables.Count > 0) { int intCount = dataSet.Tables[0].Rows.Count; bool result = false; string strMcdCode = string.Empty; if (intCount > 0) { for (int i = 0; i < intCount; i++) { strMcdCode = dataSet.Tables[0].Rows[i]["McdCode"].ToString(); result = DownMcdPicFile(dataSet.Tables[0].Rows[i]["McdPic"].ToString(), dataSet.Tables[0].Rows[i]["Url"].ToString()); if (result) { // 下载成功,删除商品图片下载临时表记录 strSql = "delete T_MCD_PICTEMP where McdCode = '" + strMcdCode + "' and Status = '0'"; result = dbOper.excuteSql(strSql); } } } } } catch { } finally { dbOper.closeConnection(); } }
/// <summary> /// 更新系统配置参数值 /// </summary> /// <param name="cfgName"></param> /// <param name="value"></param> /// <returns></returns> public bool UpdatePaymentName(string payCode, string nameCN, string nameEN, string nameRUS) { bool result = false; try { string strSql = "update T_SYS_PAYMENT set [Name_CN] = '" + nameCN + "',[Name_EN] = '" + nameEN + "',[Name_RUS] = '" + nameRUS + "' where [PayMentCode]='" + payCode + "'"; DbOper dbOper = new DbOper(); dbOper.DbFileName = _m_DbFileName; dbOper.ConnType = ConnectType.CloseConn; result = dbOper.excuteSql(strSql); dbOper.closeConnection(); } catch { result = false; } return(result); }
/// <summary> /// 获取机器当日货币统计数据 /// </summary> /// <returns>当日货币统计数据</returns> public DataSet GetMoneyStatInfo() { DbOper dbOper = new DbOper(); dbOper.DbFileName = _m_DbFileName; DataSet dataSet = new DataSet(); try { string strSql = @"select TodayCashMoney,TodayCashNum,TodayCoinRecMoney,TodayCoinRecNum, TodayCoinChangeMoney,TodayCoinChangeNum from T_MONEY_STAT"; dataSet = dbOper.dataSet(strSql); } catch { } finally { dbOper.closeConnection(); } return(dataSet); }
/// <summary> /// 获取机器销售统计数据 /// </summary> /// <returns>销售统计数据</returns> public DataSet GetSaleStatInfo() { DbOper dbOper = new DbOper(); dbOper.DbFileName = _m_DbFileName; DataSet dataSet = new DataSet(); try { string strSql = @"select BeginDate,TotalSaleMoney,TotalSaleNum, CycleDate,CycleSaleMoney,CycleSaleNum,TodaySaleMoney,TodaySaleNum from T_SALE_STAT"; dataSet = dbOper.dataSet(strSql); } catch { } finally { dbOper.closeConnection(); } return(dataSet); }
/// <summary> /// 更新广告文件状态 /// </summary> /// <param name="advertInfo"></param> /// <param name="status">0:等待更新 1:更新中 2:成功 3:失败</param> /// <returns></returns> public bool UpdateAdvFileStatus(AdvertInfoModel advertInfo, string status) { bool result = false; DbOper dbOper = new DbOper(); dbOper.DbFileName = _m_DbFileName; try { string strSql = "update T_ADV_ADVFILE set Status = '" + status + "' where AdvListID = '" + advertInfo.AdvListID + "' and FileCode = '" + advertInfo.FileCode + "'"; result = dbOper.excuteSql(strSql); } catch { result = false; } finally { dbOper.closeConnection(); } return(result); }
public void LoadPaymentName() { try { DbOper dbOper = new DbOper(); dbOper.DbFileName = _m_DbFileName; string strSql = @"select PayMentCode,Name_CN,Name_EN,Name_RUS from T_SYS_PAYMENT "; DataSet dataSet = dbOper.dataSet(strSql); if (dataSet.Tables.Count > 0) { int intCount = dataSet.Tables[0].Rows.Count; string strPayCode = string.Empty; if (intCount > 0) { for (int i = 0; i < intCount; i++) { strPayCode = dataSet.Tables[0].Rows[i]["PayMentCode"].ToString(); switch (strPayCode) { case "IcCard": // 一卡通 PaymentList.IC.Name_CN = dataSet.Tables[0].Rows[i]["Name_CN"].ToString(); PaymentList.IC.Name_EN = dataSet.Tables[0].Rows[i]["Name_EN"].ToString(); PaymentList.IC.Name_RUS = dataSet.Tables[0].Rows[i]["Name_RUS"].ToString(); break; } } } } dbOper.closeConnection(); } catch { } }
/// <summary> /// 加载商品类型信息 /// </summary> /// <returns></returns> public bool LoadGoodsTypeList() { bool result = false; GoodsTypeList.Clear(); DbOper dbOper = new DbOper(); dbOper.DbFileName = _m_DbFileName; try { string strSql = string.Empty; strSql += @"select TypeCode,TypeName from T_MCD_TYPE order by TypeCode desc"; DataSet dataSet = dbOper.dataSet(strSql); int recordCount = 0; if (dataSet.Tables.Count > 0) { recordCount = dataSet.Tables[0].Rows.Count; string strTypeCode = string.Empty; int intTypeCount = 0; DataSet ds_Num = new DataSet(); for (int i = 0; i < recordCount; i++) { strTypeCode = dataSet.Tables[0].Rows[i]["TypeCode"].ToString(); #region 获取该类别商品下的商品数量 intTypeCount = 0; strSql = @"select distinct t2.mcdname from t_vm_painfo t1,t_mcd_baseinfo t2,T_MCD_TYPE t3 where t1.mcdcode = t2.mcdcode and t1.pakind = '0' and t2.mcdtype = t3.typecode and t2.mcdtype = '" + strTypeCode + "'"; ds_Num = dbOper.dataSet(strSql); if (ds_Num.Tables.Count > 0) { intTypeCount = ds_Num.Tables[0].Rows.Count; } #endregion GoodsTypeList.Add(new GoodsTypeModel() { TypeCode = strTypeCode, TypeName = dataSet.Tables[0].Rows[i]["TypeName"].ToString(), GoodsCount = intTypeCount, }); } } result = true; } catch { result = false; } finally { dbOper.closeConnection(); } return(result); }
/// <summary> /// 检查当前更新的广告节目单是否可以播放 /// </summary> /// <param name="advListID"></param> /// <returns></returns> public bool CheckUploadAdvIsPlay(string advListID) { bool result = false; DbOper dbOper = new DbOper(); dbOper.DbFileName = _m_DbFileName; try { if (string.IsNullOrEmpty(advListID)) { result = false; return(result); } dbOper.ConnType = ConnectType.KeepConn; #region 检查该广告节目单的开始播放日期是否到 string strSql = @"select BeginDate,TotalNum from T_ADV_ADVLIST where AdvListID = '" + advListID + "'"; int intCount = 0; bool blnIsDate = false; int intTotalNum = 0; DataSet dataSet = dbOper.dataSet(strSql); if (dataSet.Tables.Count > 0) { intCount = dataSet.Tables[0].Rows.Count; if (intCount > 0) { long intBeginDate = Convert.ToInt64(dataSet.Tables[0].Rows[0]["BeginDate"].ToString()); long intNowDate = Convert.ToInt64(DateTime.Now.ToString("yyyyMMdd")); intTotalNum = Convert.ToInt32(dataSet.Tables[0].Rows[0]["TotalNum"].ToString()); if (intNowDate >= intBeginDate) { // 到达播放日期 blnIsDate = true; } } } #endregion if (blnIsDate) { // 检查该广告节目单里的广告文件是否全部准备到位 strSql = @"select AdvListID from T_ADV_ADVFILE where AdvListID = '" + advListID + "' and status = '2'"; dataSet = dbOper.dataSet(strSql); if (dataSet.Tables.Count > 0) { intCount = dataSet.Tables[0].Rows.Count; if (intCount >= intTotalNum) { // 广告文件全部更新完毕 result = true; } } } } catch { result = false; } finally { dbOper.closeConnection(); } return(result); }
/// <summary> /// 批量添加商品 /// </summary> /// <param name="goodsListInfo">商品列表的JSON格式</param> /// <param name="importType">导入方式 0:本地导入 1:远程下载</param> /// <param name="picSourcePath">本地导入时的商品图片来源路径</param> /// <returns>结果 0:成功 1:获取商品导入信息失败 2:没有要导入的商品信息 3:导入失败</returns> public int ImportGoodsList(string goodsListInfo, string importType, string picSourcePath, out string updateMcdList) { int intErrCode = 0; updateMcdList = string.Empty; try { JsonOper jsonOper = new JsonOper(); string strResultCode = jsonOper.GetJsonKeyValue(goodsListInfo, "ret"); if (strResultCode == "0") { int intGoodsCount = 0; intGoodsCount = Convert.ToInt32(jsonOper.GetJsonKeyValue(goodsListInfo, "count")); if (intGoodsCount == 0) { intErrCode = 2;// 没有要导入的商品信息 } else { string strMcdCode = string.Empty; string strMcdName = string.Empty; string strMcdContent = string.Empty; string strMcdType = string.Empty; string strMcdPic = string.Empty; string strIsFree = "0"; string strManufacturer = string.Empty; string strGoodsSpec = string.Empty; string strDrugType = "0"; string strDetailInfo = string.Empty; string strMcdUnit = string.Empty; string strMcdSaleType = string.Empty; string strUrl = string.Empty; JsonData jdItems = null; string strSql = string.Empty; DbOper dbOper = new DbOper(); dbOper.DbFileName = _m_DbFileName; dbOper.ConnType = ConnectType.CloseConn; DataSet dataSet = new DataSet(); jdItems = JsonMapper.ToObject(goodsListInfo); jdItems = jdItems["goodslist"]; bool blnIsExit = false; bool result = false; #region 检查是否存在新的字段 bool blnIsExitIsFree = false;// 是否存在免费字段 False:不存在 True:存在 if (goodsListInfo.IndexOf("isfree") > 10) { blnIsExitIsFree = true; } bool blnIsExitManufacturer = false;// 是否存在生产厂商 False:不存在 True:存在 if (goodsListInfo.IndexOf("manufacturer") > 10) { blnIsExitManufacturer = true; } bool blnIsExitUnit = false;// 是否存在单位 False:不存在 True:存在 if (goodsListInfo.IndexOf("unit") > 10) { blnIsExitUnit = true; } bool blnIsExitGoodsSpec = false;// 是否存在商品规格 False:不存在 True:存在 if (goodsListInfo.IndexOf("goodsspec") > 10) { blnIsExitGoodsSpec = true; } bool blnIsExitDrugType = false;// 是否存在商品标示 False:不存在 True:存在 if (goodsListInfo.IndexOf("drugtype") > 10) { blnIsExitDrugType = true; } bool blnIsExitDetail = false;// 是否存在商品详细介绍 False:不存在 True:存在 if (goodsListInfo.IndexOf("detail") > 10) { blnIsExitDetail = true; } bool blnIsExitMcdSaleType = false;// 是否存在商品销售类型 False:不存在 True:存在 if (goodsListInfo.IndexOf("saletype") > 10) { blnIsExitMcdSaleType = true; } bool blnIsExitPicUrl = false;// 是否存在商品图片下载URL False:不存在 True:存在 if (goodsListInfo.IndexOf("picurl") > 10) { blnIsExitPicUrl = true; } #endregion #region 遍历商品导入信息 foreach (JsonData item in jdItems) { strMcdCode = item["mcdcode"].ToString(); strMcdName = item["mcdname"].ToString(); strMcdContent = item["mcdcontent"].ToString(); strMcdPic = item["mcdpic"].ToString(); strMcdType = item["mcdtype"].ToString(); if (blnIsExitIsFree) { strIsFree = item["isfree"].ToString(); } if (blnIsExitManufacturer) { strManufacturer = item["manufacturer"].ToString(); } if (blnIsExitUnit) { strMcdUnit = item["unit"].ToString(); } if (blnIsExitGoodsSpec) { strGoodsSpec = item["goodsspec"].ToString(); } if (blnIsExitDrugType) { strDrugType = item["drugtype"].ToString(); } if (blnIsExitDetail) { strDetailInfo = item["detail"].ToString(); // 转码商品详细介绍中的换行符等 strDetailInfo = strDetailInfo.Replace("\\r", "\r"); strDetailInfo = strDetailInfo.Replace("\\n", "\n"); } if (blnIsExitMcdSaleType) { strMcdSaleType = item["saletype"].ToString(); } else { strMcdSaleType = "0"; } if (blnIsExitPicUrl) { strUrl = item["picurl"].ToString(); } // 检查是否已经存在了该商品,如果已经存在该商品编号,则更新;否则添加 strSql = "select McdCode from T_MCD_BASEINFO where mcdcode = '" + strMcdCode + "'"; blnIsExit = false; dataSet = dbOper.dataSet(strSql); if (dataSet.Tables.Count > 0) { if (dataSet.Tables[0].Rows.Count > 0) { blnIsExit = true; } } if (blnIsExit) { // 已经存在,则更新 strSql = @"update T_MCD_BASEINFO set McdName = '" + strMcdName + "'," + "McdContent = '" + strMcdContent + "'," + "PicName = '" + strMcdPic + "',IsFree = '" + strIsFree + "',manufacturer = '" + strManufacturer + "',GoodsSpec = '" + strGoodsSpec + "',DrugType = '" + strDrugType + "',McdType = '" + strMcdType + "',Unit = '" + strMcdUnit + "',DetailInfo = '" + strDetailInfo + "',McdSaleType = '" + strMcdSaleType + "' where mcdcode = '" + strMcdCode + "'"; updateMcdList += strMcdCode + ","; } else { // 不存在,则添加 strSql = @"insert into T_MCD_BASEINFO(McdCode,McdName,McdContent, PicName,Price,IsFree,manufacturer, GoodsSpec,DrugType,McdType,Unit,DetailInfo,McdSaleType) values('" + strMcdCode + "','" + strMcdName + "','" + strMcdContent + "','" + strMcdPic + "'," + "0" + ",'" + strIsFree + "','" + strManufacturer + "','" + strGoodsSpec + "','" + strDrugType + "','" + strMcdType + "','" + strMcdUnit + "','" + strDetailInfo + "','" + strMcdSaleType + "')"; } result = dbOper.excuteSql(strSql); if (result) { switch (importType) { case "0": // 本地导入商品信息 #region 拷贝商品图片 if (File.Exists(picSourcePath + strMcdPic)) { try { // 存在商品图片,拷贝覆盖 File.Copy(picSourcePath + strMcdPic, AppDomain.CurrentDomain.BaseDirectory.ToString() + "Images\\GoodsPic\\" + strMcdPic, true); } catch { } } #endregion break; case "1": // 远程下载更新商品信息 #region 商品图片信息先保存,再另外下载图片 if (!File.Exists(picSourcePath + strMcdPic)) { // 添加到商品图片下载中间表 strSql = @"insert into T_MCD_PICTEMP(McdCode,McdPic,Url,Status) values('" + strMcdCode + "','" + strMcdPic + "','" + strUrl + "','0')"; result = dbOper.excuteSql(strSql); } #endregion break; } } } #endregion dbOper.closeConnection(); // 更新商品列表 LoadGoodsInfo_Total(); } } else { intErrCode = 1; } } catch { intErrCode = 3;// 导入失败 } return(intErrCode); }
/// <summary> /// 清除指定类型货币库存 /// </summary> /// <param name="cashType">货币类型 0:硬币 1:纸币</param> /// <param name="operType">清除类型 0:全部库存 1:正轨途径库存(如:币筒、Hopper、钞箱) 2:非正轨途径库存(如:溢币盒、纸币找零器)</param> /// <returns></returns> public bool ClearCashStockNum_All(string cashType, string operType) { bool result = false; string strSql = string.Empty; try { switch (operType) { case "0": // 全部库存 strSql = "update T_VM_CASHINFO set StockNum = 0,BoxStockNum = 0 where CashType = '" + cashType + "'"; break; case "1": // 正轨途径库存 strSql = "update T_VM_CASHINFO set StockNum = 0 where CashType = '" + cashType + "'"; break; case "2": // 非正轨途径库存 strSql = "update T_VM_CASHINFO set BoxStockNum = 0 where CashType = '" + cashType + "'"; break; } DbOper dbOper = new DbOper(); dbOper.DbFileName = _m_DbFileName; dbOper.ConnType = ConnectType.CloseConn; result = dbOper.excuteSql(strSql); dbOper.closeConnection(); if (result) { int intListCount = CashInfoList.Count; for (int i = 0; i < intListCount; i++) { if (CashInfoList[i].CashType == cashType) { switch (operType) { case "0": // 全部库存 CashInfoList[i].StockNum = 0; CashInfoList[i].BoxStockNum = 0; break; case "1": // 正轨途径库存 CashInfoList[i].StockNum = 0; break; case "2": // 非正轨途径库存 CashInfoList[i].BoxStockNum = 0; break; } } } } } catch { result = false; } return(result); }
/// <summary> /// 增加或减少或覆盖某货币面值库存 /// </summary> /// <param name="cashValue"></param> /// <param name="stockNum"></param> /// <param name="cashType"></param> /// <param name="source">货币进入途径 0:不属于进入 /// 1:进入正轨途径,硬币进入币筒,纸币进入钞箱 2:进入非正轨途径,硬币进入溢币盒,纸币进入找零器</param> /// <param name="type">更改类型 0:增加 1:减少 2:覆盖</param> /// <returns></returns> public bool UpdateCashStockNum(int cashValue, int stockNum, string cashType, string source, string type) { bool result = false; string strSql = string.Empty; string strStockComm = "StockNum"; try { switch (source) { case "1": // strStockComm = "StockNum"; // 修改的是其正轨途径进入的库存数量 break; case "2": // strStockComm = "BoxStockNum"; // 修改的是其非正轨途径进入的库存数量 break; case "0": // if (cashType == "0") { // 如果是硬币 strStockComm = "StockNum"; } else { // 如果是纸币 strStockComm = "BoxStockNum"; } break; } int intListCount = CashInfoList.Count; for (int i = 0; i < intListCount; i++) { if ((CashInfoList[i].CashValue == cashValue) && (CashInfoList[i].CashType == cashType)) { switch (type) { case "0": // 增加 strSql = "update T_VM_CASHINFO set " + strStockComm + " = " + strStockComm + " + " + stockNum + " where CashValue = '" + cashValue + "' and CashType = '" + cashType + "'"; break; case "1": // 减少 strSql = "update T_VM_CASHINFO set " + strStockComm + " = " + strStockComm + " - " + stockNum + " where CashValue = '" + cashValue + "' and CashType = '" + cashType + "'"; break; case "2": // 覆盖 strSql = "update T_VM_CASHINFO set " + strStockComm + " = " + stockNum + " where CashValue = '" + cashValue + "' and CashType = '" + cashType + "'"; break; } DbOper dbOper = new DbOper(); dbOper.DbFileName = _m_DbFileName; dbOper.ConnType = ConnectType.CloseConn; result = dbOper.excuteSql(strSql); dbOper.closeConnection(); if (result) { switch (type) { case "0": if (strStockComm == "StockNum") { CashInfoList[i].StockNum = CashInfoList[i].StockNum + stockNum; } else if (strStockComm == "BoxStockNum") { CashInfoList[i].BoxStockNum = CashInfoList[i].BoxStockNum + stockNum; } break; case "1": if (strStockComm == "StockNum") { CashInfoList[i].StockNum = CashInfoList[i].StockNum - stockNum; } else if (strStockComm == "BoxStockNum") { CashInfoList[i].BoxStockNum = CashInfoList[i].BoxStockNum - stockNum; } break; case "2": if (strStockComm == "StockNum") { CashInfoList[i].StockNum = stockNum; } else if (strStockComm == "BoxStockNum") { CashInfoList[i].BoxStockNum = stockNum; } break; } } break; } } } catch { result = false; } return(result); }
/// <summary> /// 导入广告文件信息 /// </summary> /// <param name="goodsListInfo">列表的JSON格式</param> /// <param name="importType">导入方式 0:本地导入 1:远程下载</param> /// <param name="picSourcePath">本地导入时的来源路径</param> /// <returns>结果 0:成功 1:获取导入信息失败 2:没有要导入的信息 3:导入失败</returns> public int ImportAdvertList(string advertListInfo, string importType, string sourcePath, out string updateList) { int intErrCode = 0; updateList = string.Empty; DbOper dbOper = new DbOper(); dbOper.DbFileName = _m_DbFileName; try { AdvertList_Import.Clear(); JsonOper jsonOper = new JsonOper(); string strResultCode = jsonOper.GetJsonKeyValue(advertListInfo, "ret"); string strisupdate = jsonOper.GetJsonKeyValue(advertListInfo, "isupdate"); if ((strResultCode == "0") && (strisupdate == "1")) { #region int intCount = 0; intCount = Convert.ToInt32(jsonOper.GetJsonKeyValue(advertListInfo, "advcount")); string strAdvListID = jsonOper.GetJsonKeyValue(advertListInfo, "advlistid"); string strUpdateSign = jsonOper.GetJsonKeyValue(advertListInfo, "updatesign"); string strPlaySign = jsonOper.GetJsonKeyValue(advertListInfo, "playsign"); string strBeginDate = jsonOper.GetJsonKeyValue(advertListInfo, "begindate"); string strEndDate = jsonOper.GetJsonKeyValue(advertListInfo, "enddate"); if (intCount == 0) { intErrCode = 2;// 没有要导入的信息 } else if (strAdvListID == m_UpdateAdvertListID) { // 当前要导入的广告节目单编号和正在更新的广告节目单编号一样 intErrCode = 2;// 没有要导入的信息 } else { // 检查以广告节目单编号为名称的文件夹是否存在,如果不存在,自动创建 CreateDirectory(strAdvListID); string strSql = string.Empty; bool result = false; #region 操作广告节目单表 dbOper.ConnType = ConnectType.KeepConn; strSql = @"select FileCode from T_ADV_ADVFILE where AdvListID = '" + strAdvListID + "'"; DataSet dataSet = dbOper.dataSet(strSql); bool blnIsExist = false;// 是否已经存在该节目单 False:不存在 True:存在 if (dataSet.Tables.Count > 0) { if (dataSet.Tables[0].Rows.Count > 0) { // 已经存在该广告节目单,更新 blnIsExist = true; } } if (blnIsExist) { // 更新 strSql = "update T_ADV_ADVLIST set UpdateSign = '" + strUpdateSign + "',PlaySign = '" + strPlaySign + "',TotalNum = '" + intCount + "',BeginDate = '" + strBeginDate + "',EndDate = '" + strEndDate + "',Content = '" + advertListInfo + "',ImportType = '" + importType + "' where AdvListID = '" + strAdvListID + "'"; } else { // 添加 strSql = @"insert into T_ADV_ADVLIST(AdvListID,UpdateSign,PlaySign,TotalNum,BeginDate,EndDate,Content,ImportType) values('" + strAdvListID + "','" + strUpdateSign + "','" + strPlaySign + "','" + intCount + "','" + strBeginDate + "','" + strEndDate + "','" + advertListInfo + "','" + importType + "')"; } result = dbOper.excuteSql(strSql); if (!result) { intErrCode = 3; } #endregion if (result) { JsonData jdItems = null; jdItems = JsonMapper.ToObject(advertListInfo); jdItems = jdItems["filelist"]; #region 遍历导入信息 string strAdvCode = string.Empty; string strFileName = string.Empty; string strFileFormat = string.Empty; string strSize = string.Empty; string strPlayNum = string.Empty; string strDelayTime = string.Empty; string strUrl = string.Empty; string strSource = string.Empty; int intNo = 0; string strFactImportType = string.Empty; foreach (JsonData item in jdItems) { intNo++; strAdvCode = item["advcode"].ToString(); strFileName = item["name"].ToString(); strFileFormat = item["format"].ToString(); strSize = item["size"].ToString(); strPlayNum = item["playnum"].ToString(); strDelayTime = item["delaytime"].ToString(); strUrl = item["url"].ToString(); strSource = item["source"].ToString(); if (importType == "0") { strFactImportType = "0"; } else { strFactImportType = strSource; } // 保存表记录 strSql = @"insert into T_ADV_ADVFILE(AdvListID,FileCode,FileName,FileFormat, FileType,FileSize,PlayNum,DelayTime,DownUrl,Status,ImportType) values('" + strAdvListID + "','" + strAdvCode + "','" + strFileName + "','" + strFileFormat + "','1','" + strSize + "','" + strPlayNum + "','" + strDelayTime + "','" + strUrl + "','0','" + strFactImportType + "')"; result = dbOper.excuteSql(strSql); ////AdvertList_Import.Add(new AdvertInfoModel() ////{ //// PlayNo = intNo - 1, //// FileName = strFileName, //// FileType = strFileType, //// AdvertType = GetAdvertFileType(strFileType), ////}); } #endregion if (intNo == 0) { intErrCode = 2;// 没有要导入的信息 } else { m_UpdateAdvertListID = strAdvListID; } } } #endregion } else if ((strResultCode == "0") && (strisupdate == "0")) { intErrCode = 2; } else { intErrCode = 1; } dbOper.closeConnection(); } catch { dbOper.closeConnection(); intErrCode = 3;// 导入失败 } return(intErrCode); }
/// <summary> /// 加载商品信息列表—上架 /// </summary> /// <param name="pageNum">每页显示的最大行数</param> /// <param name="rowNum">每行显示的最大列数</param> /// <returns></returns> public bool LoadGoodsInfo_Show(int eachPageMaxRowNum, int eachRowMaxNum) { bool result = false; GoodsList_Show.Clear(); GoodsShowPageCount = 0; CurrentPageNo = 1; DbOper dbOper = new DbOper(); dbOper.DbFileName = _m_DbFileName; try { string strSql = string.Empty; strSql += @"select distinct t1.mcdcode,t2.mcdname,t2.mcdcontent,t2.picname,t1.sellprice, t2.IsFree,t2.Manufacturer,t2.GoodsSpec, t2.DrugType,t2.McdType,t2.Unit,t2.DetailInfo,t2.McdSaleType from t_vm_painfo t1,t_mcd_baseinfo t2 where t1.mcdcode = t2.mcdcode and t1.pakind = '0' and t1.sellmodel = '0' order by t1.pacode_num"; DataSet dataSet = dbOper.dataSet(strSql); if (dataSet.Tables.Count > 0) { int recordCount = dataSet.Tables[0].Rows.Count; // 获取总页面 int intEachMaxNum = eachPageMaxRowNum * eachRowMaxNum;// 每页显示的最大商品数量 GoodsShowPageCount = ((recordCount / intEachMaxNum) + ((recordCount % intEachMaxNum) > 0 ? 1 : 0)); string strSql12 = string.Empty; string strMcdCode = string.Empty; int intSellPrice = 0; int intSurNum = 0; string strStockNum = string.Empty; DataSet dataSet_Sur = new DataSet(); for (int i = 0; i < recordCount; i++) { strMcdCode = dataSet.Tables[0].Rows[i]["McdCode"].ToString(); intSellPrice = Convert.ToInt32(dataSet.Tables[0].Rows[i]["sellprice"].ToString()); // 查询每个商品当前的库存 intSurNum = 0; strSql12 = @"select sum(surnum) as surnum from t_vm_painfo where pakind = '0' and mcdcode = '" + strMcdCode + "' and sellprice = " + intSellPrice; dataSet_Sur = dbOper.dataSet(strSql12); if (dataSet_Sur.Tables.Count > 0) { if (dataSet_Sur.Tables[0].Rows.Count > 0) { strStockNum = dataSet_Sur.Tables[0].Rows[0]["surnum"].ToString(); intSurNum = Convert.ToInt32(strStockNum); } } GoodsList_Show.Add(new GoodsModel() { McdCode = strMcdCode, McdName = dataSet.Tables[0].Rows[i]["McdName"].ToString(), McdContent = dataSet.Tables[0].Rows[i]["McdContent"].ToString(), PicName = dataSet.Tables[0].Rows[i]["PicName"].ToString(), Price = intSellPrice, Unit = dataSet.Tables[0].Rows[i]["Unit"].ToString(), SurNum = intSurNum, IsFree = dataSet.Tables[0].Rows[i]["IsFree"].ToString(), Manufacturer = dataSet.Tables[0].Rows[i]["Manufacturer"].ToString(), GoodsSpec = dataSet.Tables[0].Rows[i]["GoodsSpec"].ToString(), DrugType = dataSet.Tables[0].Rows[i]["DrugType"].ToString(), TypeCode = dataSet.Tables[0].Rows[i]["McdType"].ToString(), DetailInfo = dataSet.Tables[0].Rows[i]["DetailInfo"].ToString(), McdSaleType = FunHelper.ChangeMcdSaleType(dataSet.Tables[0].Rows[i]["McdSaleType"].ToString()), }); } } result = true; } catch { result = false; } finally { dbOper.closeConnection(); } return(result); }