/// <summary> /// 根据传入的打印数量,加载相应数量的标签 /// </summary> /// <param name="count"></param> /// <returns></returns> private string GetQBCodeSql(int count) { //获取当前模板前缀 Model.QB_ModelEL model = new Model.QB_ModelEL { ID = GetTemplateId() }; DataTable dt_Model = model.ExecDT(4); string strpre = ""; if (dt_Model.Rows.Count > 0) { strpre = dt_Model.Rows[0]["ENTag"].ToString(); } string mainIdS = GetQueryString("mainId"); long mainId = 0; if (mainIdS != string.Empty) { mainId = long.Parse(mainIdS); } string sql = "select top " + count + " * from QB_Code Where [Valid]='1' and MainID=" + mainId + " and PrintNum=0 and QBCode like '" + strpre + "%'"; return(sql); }
protected void BindInputPageValue() { //获取当前模板前缀 Model.QB_ModelEL model = new Model.QB_ModelEL { ID = GetId() }; DataTable dt_Model = model.ExecDT(4); string strpre = ""; if (dt_Model.Rows.Count > 0) { strpre = dt_Model.Rows[0]["ENTag"].ToString(); } Model.QB_CodeEL qbCode = new Model.QB_CodeEL() { MainID = 0, QBCode = strpre }; DataTable dt = new DataTable(); dt = qbCode.ExecDT(59);//此服务商下面还没有打印的二维码 if (dt != null) { this.lblNotPrintNum.Text = dt.Rows.Count.ToString(); } else { this.lblNotPrintNum.Text = "0"; } }
/// <summary> /// 判断空白标签是否已经有此前缀 /// </summary> private bool IshaveENTag() { bool returnResult = false; #region 前缀判断 //前缀判断(不能用空白标签的前缀) Model.QB_ModelEL qbTmplt = new Model.QB_ModelEL() { MainID = 0, ENTag = tb_entag.Text.Trim() }; DataTable dateQB_Model01 = qbTmplt.ExecDT(54);// //判断本服务商是否已用此前缀 qbTmplt.MainID = long.Parse(hf_mid.Value.ToString()); DataTable dateQB_Model02 = qbTmplt.ExecDT(54);// if (dateQB_Model01.Rows.Count > 0 || dateQB_Model02.Rows.Count > 0) { MessageBox.Show(this, "前缀已经使用请重新输入!"); returnResult = true; } #endregion return(returnResult); }
/// <summary> /// 生成新的二维码编号 /// </summary> /// <param name="qbCode"></param> /// <returns>前两位为字母,后面为数字</returns> protected string GenerateQBCode(string qbCode) { string newCode = string.Empty; //前缀修改为从数据库读取 Model.QB_ModelEL model = new Model.QB_ModelEL { ID = GetId() }; DataTable dt = model.ExecDT(4); string strpre = ""; if (dt.Rows.Count > 0) { strpre = dt.Rows[0]["ENTag"].ToString(); } try { if (string.IsNullOrEmpty(qbCode)) { newCode = strpre + "00000001"; } else { newCode = qbCode.Substring(strpre.Length); newCode = strpre + ((long.Parse(newCode) + 1).ToString().PadLeft(8, '0')); } } catch (Exception er) { HF.Cloud.BLL.Common.Logger.Error(qbCode); HF.Cloud.BLL.Common.Logger.Error("newcode:" + newCode, er); } return(newCode); }
/// <summary> /// 确定 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnSubmit_Click(object sender, EventArgs e) { string tips = ValidateInputValue(); if (tips == string.Empty) { DataTable dt = new DataTable(); string maxQBCode = string.Empty; string scpt = string.Empty; string mainIdS = GetQueryString("mainId"); long mainId = 0; if (mainIdS != string.Empty) { mainId = long.Parse(mainIdS); } //前缀修改为从数据库读取 Model.QB_ModelEL model = new Model.QB_ModelEL { ID = GetId() }; DataTable dt_Model = model.ExecDT(4); string strpre = ""; if (dt_Model.Rows.Count > 0) { strpre = dt_Model.Rows[0]["ENTag"].ToString(); } Model.QB_CodeEL qbCode = new Model.QB_CodeEL() { MainID = mainId, QBCode = strpre //这里QBCode只是前缀,存储过程中用来查找有此前缀的二维码 }; dt = qbCode.ExecDT(53); if (dt != null && dt.Rows.Count > 0) //获取最大的标签 { maxQBCode = dt.Rows[0]["QBCode"].ToString(); //注释掉的话就可以从0开始打印标签了 //maxQBCode = "wsjd00002519";//用这个可以从HF00000101开始打印标签了 } if (this.rblPrintSelect.SelectedValue == "1") { string newQBCode = string.Empty;//新的标签号 long startId = 0; long endId = 0; string qbCodeUriPath = CommonDAL.ConfigHelper.GetConfigString("QBCodeUrlPath"); int gnum = 0; gnum = int.Parse(this.txtPrintNum.Text.Trim()); newQBCode = GenerateQBCode(maxQBCode); for (int i = 0; i < gnum; i++) { if (newQBCode != string.Empty) { if (i == 0) { startId = CreatCode(qbCodeUriPath + "?mid=" + mainId + "&cid=" + newQBCode, newQBCode); } else if (i == gnum - 1) { endId = CreatCode(qbCodeUriPath + "?mid=" + mainId + "&cid=" + newQBCode, newQBCode); } else { CreatCode(qbCodeUriPath + "?mid=" + mainId + "&cid=" + newQBCode, newQBCode); } newQBCode = GenerateQBCode(newQBCode); } } if (gnum == 1) { endId = startId; } //pt 打印类型 //pn 打印数量 if (startId > 0 && endId > 0) { scpt = "open('" + "QBCodePrint.aspx?sid=" + startId + "&eid=" + endId + "&pt=newprint" + "&tid=" + GetId() + "&mainId=" + mainId + "');"; BLL.Common.MessageBox.ResponseScript(this, scpt); //BLL.Common.MessageBox.Redirect(this, "/QBCode/QBCodePrint.aspx?sid=" + startId + "&eid=" + endId + "&pt=newprint" + "&tid=" + GetId()); } } else if (this.rblPrintSelect.SelectedValue == "2") { scpt = "open('" + "QBCodePrint.aspx?pn=" + this.txtPrintNum.Text.Trim() + "&pt=oldprint" + "&tid=" + GetId() + "&mainId=" + mainId + "');"; BLL.Common.MessageBox.ResponseScript(this, scpt); //BLL.Common.MessageBox.Redirect(this, "/QBCode/QBCodePrint.aspx?pn=" + this.txtPrintNum.Text.Trim() + "&pt=oldprint" + "&tid=" + GetId()); } } else { BLL.Common.MessageBox.Show(this, tips); } }