/// <summary>
        /// 插入新的二维码记录
        /// </summary>
        /// <returns></returns>
        public long AddNewQBCodeToTable(string qbCode, string qbCodeImagePath, string QBDetail)
        {
            string mainIdS = GetQueryString("mainId");
            long   mainId  = 0;

            if (mainIdS != string.Empty)
            {
                mainId = long.Parse(mainIdS);
            }

            long returnId = 0;

            Model.QB_CodeEL model = new Model.QB_CodeEL()
            {
                MainID   = mainId,
                QBCode   = qbCode,
                QBDetail = QBDetail,
                QBPath   = qbCodeImagePath,
                AssetID  = 0,
                PrintNum = 0,
                Valid    = 1
            };

            returnId = model.ExecNonQuery(1);

            return(returnId);
        }
        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";
            }
        }
        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>
        /// <returns></returns>
        public long AddNewQBCodeToTable(string qbCode, string qbCodeImagePath, string QBDetail)
        {
            long mainId = 0;

            long returnId = 0;

            Model.QB_CodeEL model = new Model.QB_CodeEL()
            {
                MainID = mainId,
                QBCode = qbCode,
                //QBDetail = QBDetail,//生成的空标签 暂时不给地址,在分配标签时生成地址
                QBPath   = qbCodeImagePath,
                AssetID  = 0,
                PrintNum = 0,
                Valid    = 1
            };

            returnId = model.ExecNonQuery(1);

            return(returnId);
        }
Exemple #5
0
        /// <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);
            }
        }