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> /// <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); }
public void ProcessRequest(HttpContext context) { if (context.Request.Form["op"] != null) { string returnHtml = string.Empty; string op = context.Request.Form["op"]; switch (op) { case "deleteModel": //删除标签模板 { Model.QB_ModelEL model = new Model.QB_ModelEL(); model.ID = long.Parse(context.Request.Form["id"]); model.ExecNonQuery(3); returnHtml = "success"; } break; } context.Response.Write(returnHtml); } else { #region 修改标签的打印次数 string qbCodeList = GetQBCode(context); long mainId = GetMainId(context); if (qbCodeList != string.Empty) { try { if (qbCodeList.Substring(qbCodeList.Length - 1) == ",") { qbCodeList = qbCodeList.Remove(qbCodeList.Length - 1); } string[] codeList = qbCodeList.Split(new char[] { ',' }); Model.QB_CodeEL qbCode = new Model.QB_CodeEL(); foreach (string code in codeList) { qbCode.QBCode = code; qbCode.MainID = mainId; qbCode.ExecuteEL(55); qbCode.PrintNum = qbCode.PrintNum + 1; qbCode.ExecNonQuery(2); } } catch { } } #endregion } }
/// <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> 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="sender"></param> /// <param name="e"></param> protected void btnSave_Click(object sender, EventArgs e) { #region 赋值实体 Model.QB_ModelEL qbmodel = new Model.QB_ModelEL(); qbmodel.MainID = 0; qbmodel.Valid = 1; qbmodel.ImgWidth = 149; qbmodel.ImgHeight = 149; qbmodel.QBHeight = 149; qbmodel.QBWidth = 149; qbmodel.FontSize = 12; qbmodel.ENTag = tb_entag.Text; qbmodel.ModelName = tb_modelName.Text.Trim(); if (hidModel.Value == "0")//3*6 { qbmodel.Padding = "18px 25px 18px 20px"; qbmodel.QBHeight = 216; qbmodel.PrintW = 3; qbmodel.PrintH = 6; } else if (hidModel.Value == "1")//3*7 { qbmodel.Padding = "0px 25px 0px 20px"; qbmodel.QBHeight = 216; qbmodel.PrintW = 3; qbmodel.PrintH = 7; } #endregion BLL.QBModelBLL bll_qbmodel = new BLL.QBModelBLL(); if (Request.QueryString["id"] != null) { qbmodel.ID = long.Parse(Request.QueryString["id"]); } Model.QB_ModelEL qbTmplt = new Model.QB_ModelEL() { ENTag = tb_entag.Text.Trim() }; if (Request.QueryString["id"] != null) { qbTmplt.ID = long.Parse(Request.QueryString["id"].Trim()); qbTmplt.ExecuteEL(53); } else { qbTmplt.ExecuteEL(52); } if (qbTmplt.ID > 0 && qbTmplt.MainID > 0) { MessageBox.Show(this, "前缀已经使用请重新输入!"); return; } if (Request.QueryString["id"] != null) { #region 编辑 删除此原来模板的内容 添加新的内容 qbmodel.ExecNonQuery(2); List <string> qbmodeldetailstr = getQBModelDetail(); Model.QB_ModelDetailEL modeldetail = new Model.QB_ModelDetailEL(); modeldetail.QBID = qbmodel.ID; modeldetail.ExecNonQuery(31);//删除此原来模板的内容 modeldetail.MainID = 0; modeldetail.QBID = qbmodel.ID; foreach (string strdetail in qbmodeldetailstr)//循环添加新的内容 { modeldetail.QBDetail = strdetail; modeldetail.ExecNonQuery(1); } #endregion } else { //判断是否存在该名称的模板 if (bll_qbmodel.ExistsModel(qbmodel.ModelName, qbmodel.ID)) { BLL.Common.MessageBox.Show(this, "已存在相同名称的模板!"); return; } #region 新增 qbmodel.ExecuteEL(1);//插入记录 得到新插入实体 List <string> qbmodeldetailstr = getQBModelDetail(); Model.QB_ModelDetailEL modeldetail = new Model.QB_ModelDetailEL(); modeldetail.MainID = 0; modeldetail.QBID = qbmodel.ID; foreach (string strdetail in qbmodeldetailstr) { modeldetail.QBDetail = strdetail; modeldetail.ExecNonQuery(1); } #endregion } MessageBox.ShowAndRedirect(this, "保存成功!", "QBModelList.aspx"); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { if (Request.QueryString["id"] != null) { Model.QB_ModelEL qbmodel = new Model.QB_ModelEL(); qbmodel.ID = long.Parse(Request.QueryString["id"].ToString()); qbmodel.ExecuteEL(4); #region 给控件赋值 if (qbmodel.PrintH == 6) { hidModel.Value = "0"; } else { hidModel.Value = "1"; } tb_modelName.Text = qbmodel.ModelName; tb_entag.Text = qbmodel.ENTag; ltCode.Text = qbmodel.ENTag + 10000000000.ToString().Substring(qbmodel.ENTag.Trim().Length + 2) + "1";//预览处二维码 DataTable dtModelDetail = new Model.QB_ModelDetailEL() { QBID = qbmodel.ID }.ExecDT(41); if (dtModelDetail.Rows.Count > 0) { othertext1.Text = dtModelDetail.Rows[0]["QBDetail"].ToString(); lt1.Text = dtModelDetail.Rows[0]["QBDetail"].ToString(); try { othertext2.Text = dtModelDetail.Rows[1]["QBDetail"].ToString(); lt2.Text = dtModelDetail.Rows[1]["QBDetail"].ToString(); } catch { othertext2.Text = ""; } //try //{ // othertext3.Text = dtModelDetail.Rows[2]["QBDetail"].ToString(); // lt3.Text = dtModelDetail.Rows[2]["QBDetail"].ToString(); //} //catch //{ // othertext3.Text = ""; //} //try //{ // othertext4.Text = dtModelDetail.Rows[3]["QBDetail"].ToString(); // lt4.Text = dtModelDetail.Rows[3]["QBDetail"].ToString(); //} //catch //{ // othertext4.Text = ""; //} //try //{ // othertext5.Text = dtModelDetail.Rows[4]["QBDetail"].ToString(); // lt5.Text = dtModelDetail.Rows[4]["QBDetail"].ToString(); //} //catch //{ // othertext5.Text = ""; //} //try //{ // othertext6.Text = dtModelDetail.Rows[5]["QBDetail"].ToString(); // lt6.Text = dtModelDetail.Rows[5]["QBDetail"].ToString(); //} //catch //{ // othertext6.Text = ""; //} } #endregion } } }
/// <summary> /// 生成Html /// </summary> protected void GenerateHtml() { string sqlWhere = string.Empty; string pt = GetPrintType(); int pn = GetPrintNumber(); long sid = GetPrintStartId(); long eid = GetPrintEndId(); long tid = GetTemplateId(); string mainIdS = GetQueryString("mainId"); long mainId = 0; if (mainIdS != string.Empty) { mainId = long.Parse(mainIdS); } if (!string.IsNullOrEmpty(pt)) { DataTable dt = new DataTable(); DataTable detailTable = new DataTable(); Model.QB_CodeEL qbCode = new Model.QB_CodeEL(); Model.QB_ModelDetailEL modelDetail = new Model.QB_ModelDetailEL(); if (pt == "newprint") { qbCode.MainID = mainId; qbCode.ID = sid; qbCode.AssetID = eid;//结束Id dt = qbCode.ExecDT(54); } else if (pt == "oldprint") { dt = qbCode.ExecuteSqlString(GetQBCodeSql(pn)); } modelDetail.MainID = mainId; modelDetail.QBID = tid; detailTable = modelDetail.ExecDT(52); Model.QB_ModelEL model = new Model.QB_ModelEL(); model.ID = tid; model.ExecuteEL(4); if (dt != null && dt.Rows.Count > 0) { //bool isNewPage = true; for (int i = 0; i < dt.Rows.Count; i++) { #region 2017-8-30 老版本原代码01 //if (isNewPage) //{ // html.Append("<div style='height:48px;'></div><div class='bar'>"); //} //html.Append("<div class='bar-code' style='padding:" + (model.Padding == string.Empty ? "0px 25px 0px 20px" : model.Padding) + ";height:" + model.QBHeight.ToString() + "px'>"); //html.Append("<div class='barc-left'>"); //html.Append("<img src='" + dt.Rows[i]["QBPath"] + "' width='" + model.ImgWidth.ToString() + "px' height='" + model.ImgHeight.ToString() + "px' alt=''/>"); //html.Append("<div class='barc-left-code' pkey='code' pvalue='" + dt.Rows[i]["QBCode"] + "' >编号:" + dt.Rows[i]["QBCode"] + "</div>"); //html.Append("</div>"); //html.Append("<div class='barc-right'>"); //if (detailTable.Rows.Count > 0) //{ // html.Append("<h4>" + detailTable.Rows[0]["QBDetail"] + "</h4>"); // for (int j = 0; j < detailTable.Rows.Count; j++) // { // if (j == 0) // { // continue; // } // html.Append("<p>" + detailTable.Rows[j]["QBDetail"] + "</p>"); // } //} //else //{ // html.Append("<p></p>"); //} //html.Append("</div>"); #endregion #region 新代码 //html.Append("<div class='tag' style='padding:" + (model.Padding == string.Empty ? "40px 25px 0px 20px;" : model.Padding) + ";width:" + model.QBWidth + "px;height:" + model.QBHeight + "px;float:left;'>"); //html.Append("<img src='" + dt.Rows[i]["QBPath"] + "' width='" + model.ImgWidth.ToString() + "px' height='" + model.ImgHeight.ToString() + "px' alt=''/>"); //html.Append("<div class='tag-right' style=\"float:right;width:170px;margin-top:10px;margin-right:10px;\">"); //if (detailTable.Rows.Count > 0) //{ // html.Append("<h4>" + detailTable.Rows[0]["QBDetail"] + "</h4>"); // for (int j = 0; j < detailTable.Rows.Count; j++) // { // if (j == 0) // { // continue; // } // html.Append("<p>" + detailTable.Rows[j]["QBDetail"] + "</p>"); // } //} //else //{ // html.Append("<p></p>"); //} //html.Append("</div>"); //html.Append("<div style='text-align:center;width:" + model.ImgWidth.ToString() + "px;' pkey='code' pvalue='" + dt.Rows[i]["QBCode"] + "' >编号:" + dt.Rows[i]["QBCode"] + "</div>"); //html.Append("</div>"); //html.Append("</div>");//tag #endregion #region 2017-8-30老版本原代码02 //html.Append("</div>");//bar //if ((i + 1) % (model.PrintW != 0 ? (model.PrintW * model.PrintH) : 21) != 0) //{ // isNewPage = false; //} //else //{ // isNewPage = true; // html.Append("</div>"); //} //if (i == dt.Rows.Count - 1 && (i + 1) % (model.PrintW != 0 ? (model.PrintW * model.PrintH) : 21) != 0) //{ // html.Append("</div>"); //} #endregion #region 版本二 ////版本二 2017-9-5 //html.Append("<li>"); //html.Append("<div class='outer'>"); //if (detailTable.Rows.Count > 0) //{ // html.Append("<span class='tel'>" + detailTable.Rows[0]["QBDetail"] + "</span>"); //} //html.Append("<div class='inner'>"); //html.Append("<img class='QR' src='" + dt.Rows[i]["QBPath"] + "'>"); //html.Append("<span class='num' pkey='code' pvalue='" + dt.Rows[i]["QBCode"] + "'>编号:" + dt.Rows[i]["QBCode"] + "</span>"); //html.Append("</div>"); //html.Append("</div>"); //html.Append("<div class='PageNext'></div>"); //html.Append("</li>"); #endregion html.Append("<li>"); html.Append("<div class='outer'>"); if (detailTable.Rows.Count > 0) { html.Append("<span class='title'>" + detailTable.Rows[0]["QBDetail"] + "</span>"); html.Append("<span class='tel'>" + detailTable.Rows[1]["QBDetail"] + "</span>"); } html.Append("<div class='inner'>"); html.Append("<img class='QR' src='" + dt.Rows[i]["QBPath"] + "'>"); html.Append("<div class='num' pkey='code' pvalue='" + dt.Rows[i]["QBCode"] + "'>编号:" + dt.Rows[i]["QBCode"] + "</div>"); html.Append("</div>"); html.Append("</div>"); html.Append("<div class='PageNext'></div>"); html.Append("</li>"); html.Append(""); } } } }
/// <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); } }
/// <summary> /// 保存事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnSave_Click(object sender, EventArgs e) { string mainIdS = GetQueryString("mainId"); long mainId = 0; if (mainIdS != string.Empty) { mainId = long.Parse(mainIdS); } if (mainId > 0) { #region 赋值实体 Model.QB_ModelEL qbmodel = new Model.QB_ModelEL(); qbmodel.MainID = mainId; qbmodel.Valid = 1; qbmodel.ImgWidth = 149; qbmodel.ImgHeight = 149; qbmodel.QBHeight = 149; qbmodel.QBWidth = 149; qbmodel.FontSize = 12; qbmodel.ENTag = tb_entag.Text; qbmodel.ModelName = tb_modelName.Text.Trim(); if (hidModel.Value == "0")//3*6 { qbmodel.Padding = "18px 25px 18px 20px"; qbmodel.QBHeight = 216; qbmodel.PrintW = 3; qbmodel.PrintH = 6; } else if (hidModel.Value == "1")//3*7 { qbmodel.Padding = "0px 25px 0px 20px"; qbmodel.QBHeight = 216; qbmodel.PrintW = 3; qbmodel.PrintH = 7; } #endregion BLL.QBModelBLL bll_qbmodel = new BLL.QBModelBLL(); if (Request.QueryString["id"] != null) { qbmodel.ID = long.Parse(Request.QueryString["id"]); } if (Request.QueryString["id"] != null) { #region 编辑 删除此原来模板的内容 添加新的内容 //判断是否已经有此前缀,有的话则不继续执行 if (hf_entag.Value != tb_entag.Text) { if (IshaveENTag()) { return; } } qbmodel.ExecNonQuery(2); List <string> qbmodeldetailstr = getQBModelDetail(); Model.QB_ModelDetailEL modeldetail = new Model.QB_ModelDetailEL(); modeldetail.QBID = qbmodel.ID; modeldetail.ExecNonQuery(31);//删除此原来模板的内容 modeldetail.MainID = mainId; modeldetail.QBID = qbmodel.ID; foreach (string strdetail in qbmodeldetailstr)//循环添加新的内容 { modeldetail.QBDetail = strdetail; modeldetail.ExecNonQuery(1); } #endregion } else { //判断是否存在该名称的模板 if (bll_qbmodel.ExistsModel(qbmodel.ModelName, qbmodel.ID)) { BLL.Common.MessageBox.Show(this, "已存在相同名称的模板!"); return; } #region 新增 qbmodel.ExecuteEL(1);//插入记录 得到新插入实体 List <string> qbmodeldetailstr = getQBModelDetail(); Model.QB_ModelDetailEL modeldetail = new Model.QB_ModelDetailEL(); modeldetail.MainID = mainId; modeldetail.QBID = qbmodel.ID; foreach (string strdetail in qbmodeldetailstr) { modeldetail.QBDetail = strdetail; modeldetail.ExecNonQuery(1); } #endregion } MessageBox.ShowAndRedirect(this, "保存成功!", "QBModelList.aspx"); } else { MessageBox.Show(this, "没有传入相关参数!"); } }