Exemplo n.º 1
0
        string SPC_SetQueryRunUpdate(DataRow[] _rows, string _emplPwtime0)
        {
            string ret = string.Empty;
            DateTime lineDate = new DateTime(1901, 1, 1);
            StringBuilder sb = new StringBuilder();

            if (_rows.Count() > 0)
            {
                sb.AppendFormat(@"{0} ", "UPDATE PWTIME2 SET");
                for (var rowIdx = 0; rowIdx < _rows.Count(); rowIdx++)
                {
                    lineDate = _rows[rowIdx].Field<DateTime>("SHIFTDATE").Date;
                    if (rowIdx == 0)
                        sb.AppendFormat(@"{0} = N'{1}'", this.SPC_SetFieldNameByDay(lineDate.Day), _rows[rowIdx].Field<string>("TOSHIFTID").Trim());
                    else
                        sb.AppendFormat(@", {0} = N'{1}'", this.SPC_SetFieldNameByDay(lineDate.Day), _rows[rowIdx].Field<string>("TOSHIFTID").Trim());
                }
                sb.AppendFormat(@" WHERE PWTIME0 = N'{0}' AND PWYEAR = {1} AND PWMONTH = {2};", _emplPwtime0, lineDate.Year, lineDate.Month);
            }

            ret = sb.ToString();
            return ret;
        }
Exemplo n.º 2
0
        private void setSingleProperty(PropertyInfo prop, ColumnBindingAttribute attribute, DataRow[] rows, int index)
        {
            object value = null;
            if (rows != null && rows.Count() > 0)
            {
                string colName = attribute.ColNames.First();

                //May Throw Error
                DataRow dr = rows[index];

                if (dr[colName] != null && dr[colName].ToString() != "")
                {
                    value = getConvertValue(attribute, dr[colName], prop.PropertyType);
                }
            }
            setValue(prop, value, attribute);
        }
Exemplo n.º 3
0
        void RefreshMenu(DataRow[] rows)
        {
            tileControl1.Groups.Clear();
            TileGroup g = new TileGroup();
            if (rows != null && rows.Count()!=0)
            {
                tileControl1.Groups.Add(g);
                foreach (DataRow i in rows)
                {
                    TileItem ti = new TileItem { Name = i["MenuID"].ToString(), Text = i["Name"].ToString() };
                   ti.ItemClick += ti_ItemClick;
                   ti.Tag = i;
                    g.Items.Add(ti);

                }
                tileControl1.SelectedItem = g.Items[0];
                g.Items[0].AppearanceItem.Selected.BackColor = Color.Red;
                g.Items[0].AppearanceItem.Selected.BackColor2 = Color.Orange;
                g.Items[0].AppearanceItem.Selected.BorderColor = Color.White;
            }
        }
        public DataTable GetData()
        {
            IEnumerable<DataRow> rows = new DataRow[] { };
            DataTable dtResult = null;
            DataTable dt = GetDataView();

            if (dt != null)
            {
                int iRowCount = dt.Rows.Count;

                if (iRowCount > 0)
                {
                    rows = dt.Rows.Cast<DataRow>();

                    // handle paging
                    if (this.Pager != null && this.Pager.PageSize > 0)
                    {
                        if (this.Pager.PageCurrent > 0)
                        {
                            var skipN = this.Pager.PageCurrent * this.Pager.PageSize;
                            if (skipN > rows.Count())
                                skipN = rows.Count();
                            rows = rows.Skip(skipN);
                        }
                        if (this.Pager.PageSize < rows.Count())
                            rows = rows.Take(this.Pager.PageSize);
                    }

                    // handle SkipN
                    if (this.SkipN > 0 && this.SkipN < rows.Count())
                        rows = rows.Skip(this.SkipN);

                    // handle TopN
                    if (this.TopN > 0 && this.TopN < rows.Count())
                        rows = rows.Take(this.TopN);

                    // handle RandomN
                    if (this.RandomN > 0 && this.RandomN < rows.Count())
                        rows = rows.Random(this.RandomN);

                    // handle EveryNth
                    if (this.EveryNth > 0 && this.EveryNth < rows.Count())
                        rows = rows.Where((dr, index) => index % this.EveryNth == 0);
                }

                dtResult = dt.Clone();
                foreach (DataRow dr in rows)
                    dtResult.ImportRow(dr);

                // Set the assign special field values
                AssignSpecialFieldValues(dtResult);

            }
            return dtResult;
        }
Exemplo n.º 5
0
        public static List<PedidoUsuario> usuario_pedido_parse(DataRow[] rowCollection)
        {
            List<PedidoUsuario> pedidos = new List<PedidoUsuario>();
            PedidoUsuario pedido;
            ProductoPedido producto;
            int i = 0;
            DataRow row;
            int nextPedido;

            while (i < rowCollection.Count())
            {
                row = rowCollection[i];
                pedido = new PedidoUsuario();
                pedido.IdPedido = Int32.Parse(row["idPedido"].ToString());
                pedido.MontoCobrar = Int32.Parse(row["total"].ToString());
                pedido.MontoPagar = Int32.Parse(row["cuantoPaga"].ToString());
                pedido.MontoVuelto = Int32.Parse(row["vuelto"].ToString());
                pedido.Productos = new List<ProductoPedido>();

                do
                {
                    producto = new ProductoPedido();
                    producto.Nombre = row["nombre"].ToString();
                    producto.Precio = Int32.Parse(row["precioUnitario"].ToString());
                    producto.Cantidad = Int32.Parse(row["cantidad"].ToString());
                    pedido.Productos.Add(producto);

                    i++;
                    if (i < rowCollection.Count())
                    {
                        row = rowCollection[i];
                        nextPedido = Int32.Parse(row["idPedido"].ToString());
                    }
                    else
                        break;
                }
                while (nextPedido == pedido.IdPedido);

                pedidos.Add(pedido);
            }

            return pedidos;
        }
Exemplo n.º 6
0
        /// <summary>
        /// 出貨明細
        /// </summary>
        public void GetDeliverDetailsPDF()
        {
            string deliver_id = Request.Params["deliver_id"];
            _DeliverDetailMgr = new DeliverDetailMgr(mySqlConnectionString);
            DataTable deliverdetail = _DeliverDetailMgr.GetOrderDelivers(deliver_id, 1);
            BaseFont bfChinese = BaseFont.CreateFont("C:\\WINDOWS\\Fonts\\simsun.ttc,1", BaseFont.IDENTITY_H, BaseFont.NOT_EMBEDDED);
            iTextSharp.text.Font fontChinese = new iTextSharp.text.Font(bfChinese, 8, iTextSharp.text.Font.UNDERLINE, iTextSharp.text.BaseColor.RED);
            iTextSharp.text.Font font = new iTextSharp.text.Font(bfChinese, 12, iTextSharp.text.Font.NORMAL, new iTextSharp.text.BaseColor(0, 0, 0));//黑  
            string filename = "deliver_details_D" + deliver_id.PadLeft(8, '0') + ".pdf";
            Document document = new Document(PageSize.A4, (float)5, (float)5, (float)20, (float)0.5);
            string newPDFName = Server.MapPath(excelPath) + filename;
            PdfWriter writer = PdfWriter.GetInstance(document, new FileStream(newPDFName, FileMode.Create));
            document.Open();
            PdfContentByte cb = writer.DirectContent;
            cb.BeginText();
            DataRow[] singleproduct = new DataRow[] { };//單一商品
            DataRow[] fatherproduct = new DataRow[] { };//組合商品中的父商品
            DataRow[] sonproduct = new DataRow[] { };//組合商品中的子商品
            //DataRow[] normal;
            //DataRow[] low;
            //DataRow[] lowstore;
            //List<DataRow> deliverdetails = new List<DataRow>();
            ArrayList combine = new ArrayList();

            singleproduct = deliverdetail.Select(" combined_mode<=1  and ddeliver_id=" + deliver_id, "item_id asc");//單一商品
            fatherproduct = deliverdetail.Select(" combined_mode>1 and item_mode=1 and ddeliver_id=" + deliver_id, "item_id asc");//組合商品中父商品是否存在
            foreach (var item in fatherproduct)
            {
                combine.Add(item);
                sonproduct = deliverdetail.Select(" combined_mode>1  and item_mode<>1 and parent_id=" + item["parent_id"] + " and pack_id=" + item["pack_id"], "item_id asc");//對應組合商品中的子商品
                foreach (var son in sonproduct)
                {
                    son["buy_num"] = (int.Parse(son["buy_num"].ToString()) * int.Parse(son["parent_num"].ToString())).ToString();
                    combine.Add(son);
                }

            }

            List<DataRow[]> deliverdetails = new List<DataRow[]>();
            //normal = deliverdetail.Select("product_freight_set in(1,3)  and ddeliver_id=" + deliver_id, "item_id asc");//常溫
            //low = deliverdetail.Select("product_freight_set in(2,4)  and ddeliver_id=" + deliver_id, "item_id asc");//冷凍
            //lowstore = deliverdetail.Select("product_freight_set in(5,6)  and ddeliver_id=" + deliver_id, "item_id asc");//冷藏
            if (singleproduct.Count() > 0)
            {
                deliverdetails.Add(singleproduct);
            }
            if (combine.Count > 0)
            {
                deliverdetails.Add((DataRow[])combine.ToArray(typeof(DataRow)));
            }
            if (deliverdetail.Rows.Count > 0)
            {

                cb.SetFontAndSize(bfChinese, 20);
                cb.ShowTextAligned(PdfContentByte.ALIGN_LEFT, "吉甲地台灣好市集出貨明細", 30, 750, 0);
                string freight_set = string.Empty;

                switch (deliverdetail.Rows[0]["freight_set"].ToString().Trim())
                {
                    case "1":
                        freight_set = "常溫";
                        break;
                    case "2":
                        freight_set = "冷凍";
                        break;
                    case "5":
                        freight_set = "冷藏";
                        break;
                }
                cb.SetFontAndSize(bfChinese, 12);
                cb.ShowTextAligned(PdfContentByte.ALIGN_LEFT, freight_set, 350, 780, 0);
                if (deliverdetail.Rows[0]["estimated_arrival_period"].ToString() != "0")
                {
                    string estimated_arrival_period = string.Empty;
                    switch (deliverdetail.Rows[0]["estimated_arrival_period"].ToString().Trim())
                    {
                        case "0":
                            estimated_arrival_period = "不限時";
                            break;
                        case "1":
                            estimated_arrival_period = "12:00以前";
                            break;
                        case "2":
                            estimated_arrival_period = "12:00-17:00";
                            break;
                        case "3":
                            estimated_arrival_period = "17:00-20:00";
                            break;
                    }
                    cb.ShowTextAligned(PdfContentByte.ALIGN_LEFT, estimated_arrival_period, 350, 765, 0);
                }

                Phrase ph = new Phrase();
                BarCode.Code128 _Code = new BarCode.Code128();
                _Code.ValueFont = new System.Drawing.Font("宋体", 20);
                System.Drawing.Bitmap imgTemp1 = _Code.GetCodeImage("D" + deliverdetail.Rows[0]["deliver_id"].ToString().PadLeft(8, '0'), BarCode.Code128.Encode.Code128A);
                imgTemp1.Save(System.AppDomain.CurrentDomain.BaseDirectory + "\\ImportUserIOExcel\\" + "Code.gif", System.Drawing.Imaging.ImageFormat.Gif);
                iTextSharp.text.Image IMG1 = iTextSharp.text.Image.GetInstance(Server.MapPath("../ImportUserIOExcel/Code.gif"));
                IMG1.ScaleToFit(200, 30);
                Chunk ck = new Chunk(IMG1, 345, -100); //图片可设置 偏移
                ph.Add(ck);
                document.Add(ph);
                cb.SetFontAndSize(bfChinese, 10);
                cb.ShowTextAligned(PdfContentByte.ALIGN_LEFT, "付款單號:", 10, 680, 0);
                cb.ShowTextAligned(PdfContentByte.ALIGN_LEFT, "訂購時間:", 10, 660, 0);
                cb.ShowTextAligned(PdfContentByte.ALIGN_LEFT, "转单日期:", 200, 660, 0);
                cb.ShowTextAligned(PdfContentByte.ALIGN_LEFT, "订购人:", 10, 640, 0);
                cb.ShowTextAligned(PdfContentByte.ALIGN_LEFT, "收货人:", 200, 640, 0);
                string address = string.Empty;


                cb.ShowTextAligned(PdfContentByte.ALIGN_LEFT, deliverdetail.Rows[0]["order_id"].ToString(), 80, 680, 0);
                cb.ShowTextAligned(PdfContentByte.ALIGN_LEFT, deliverdetail.Rows[0]["order_createdate"].ToString() != "0" ? CommonFunction.GetNetTime(long.Parse(deliverdetail.Rows[0]["order_createdate"].ToString())).ToString("yyyy-MM-dd HH:mm:ss") : "", 80, 660, 0);
                cb.ShowTextAligned(PdfContentByte.ALIGN_LEFT, deliverdetail.Rows[0]["money_collect_date"].ToString() != "0" ? CommonFunction.GetNetTime(long.Parse(deliverdetail.Rows[0]["money_collect_date"].ToString())).ToString("yyyy-MM-dd HH:mm:ss") : "", 250, 660, 0);
                //cb.ShowTextAligned(PdfContentByte.ALIGN_LEFT, deliverdetail.Rows[0]["holiday_deliver"].ToString() == "1" ? "可" : "不可", 250, 620, 0);
                //cb.ShowTextAligned(PdfContentByte.ALIGN_LEFT, deliverdetail.Rows[0]["note_order"].ToString(), 80, 600, 0);
                cb.ShowTextAligned(PdfContentByte.ALIGN_LEFT, deliverdetail.Rows[0]["order_name"].ToString(), 80, 640, 0);
                cb.ShowTextAligned(PdfContentByte.ALIGN_LEFT, deliverdetail.Rows[0]["delivery_name"].ToString(), 250, 640, 0);
                if (deliverdetail.Rows[0]["type"].ToString() != "3")
                {
                    PdfPTable ptable = new PdfPTable(4);
                    ptable.SetTotalWidth(new float[] { 100, 320, 70, 70 });
                    PdfPCell cell = new PdfPCell();
                    cell.BorderWidth = 0.1f;
                    cell.BorderColor = new BaseColor(0, 0, 0);
                    cell = new PdfPCell(new Phrase("商品編號", font));
                    ptable.AddCell(cell);
                    cell = new PdfPCell(new Phrase("商品名稱", font));
                    ptable.AddCell(cell);
                    cell = new PdfPCell(new Phrase("數量", font));
                    ptable.AddCell(cell);
                    cell = new PdfPCell(new Phrase("售价", font));
                    ptable.AddCell(cell);
                    PdfPCell td = new PdfPCell();
                    td.BorderWidth = 0.1f;
                    int j = 0;
                    foreach (var item in deliverdetails)
                    {
                        j++;
                        for (int i = 0; i < item.Count(); i++)
                        {
                            string item_id = string.Empty;
                            if (item[i]["item_mode"].ToString() == "1")
                            {
                                item_id = item[i]["parent_id"].ToString();
                            }
                            else
                            {
                                item_id = item[i]["item_id"].ToString();
                            }
                            cell = new PdfPCell(new Phrase(item_id, font));
                            ptable.AddCell(cell);
                            string datacontent = ((item[i]["item_mode"].ToString() == "2") ? " *" : "") + item[i]["product_name"].ToString() + item[i]["product_spec_name"].ToString();
                            cell = new PdfPCell(new Phrase(item[i]["brand_name"].ToString() + "-" + datacontent, font));
                            ptable.AddCell(cell);
                            cell = new PdfPCell(new Phrase(item[i]["buy_num"].ToString(), font));
                            ptable.AddCell(cell);
                            cell = new PdfPCell(new Phrase(item[i]["item_mode"].ToString() == "1" ? "" : item[i]["single_money"].ToString(), font));
                            ptable.AddCell(cell);
                        }
                        if (deliverdetails.Count > 1 && j != deliverdetails.Count)
                        {
                            td = new PdfPCell();
                            td.Colspan = 4;
                            td.BorderWidthTop = 0.2f;
                            td.DisableBorderSide(2);
                            ptable.AddCell(td);
                        }
                    }
                    ptable.WriteSelectedRows(0, -1, 10, 620, writer.DirectContent);
                }
                else
                {
                    PdfPTable ptable = new PdfPTable(4);
                    // ptable.WidthPercentage = 90;
                    // ptable.TotalWidth = ptable.WidthPercentage;
                    ptable.SetTotalWidth(new float[] { 100, 350, 70, 70 });
                    PdfPCell cell = new PdfPCell();
                    cell.BorderWidth = 0.1f;
                    cell = new PdfPCell(new Phrase("產品細項編號", font));
                    ptable.AddCell(cell);
                    cell = new PdfPCell(new Phrase("產品名稱", font));
                    ptable.AddCell(cell);
                    cell = new PdfPCell(new Phrase("規格", font));
                    ptable.AddCell(cell);
                    cell = new PdfPCell(new Phrase("數量", font));
                    ptable.AddCell(cell);
                    int j = 0;
                    foreach (var item in deliverdetails)
                    {
                        j++;
                        for (int i = 0; i < item.Count(); i++)
                        {
                            cell = new PdfPCell(new Phrase(item[i]["item_id"].ToString(), font));
                            ptable.AddCell(cell);
                            cell = new PdfPCell(new Phrase(item[i]["brand_name"].ToString() + "-" + item[i]["product_name"].ToString(), font));
                            ptable.AddCell(cell);
                            cell = new PdfPCell(new Phrase(item[i]["product_spec_name"].ToString(), font));
                            ptable.AddCell(cell);
                            cell = new PdfPCell(new Phrase(item[i]["buy_num"].ToString(), font));
                            ptable.AddCell(cell);
                        }
                        if (deliverdetails.Count > 1 && j != deliverdetails.Count)
                        {
                            cell = new PdfPCell();
                            cell.Colspan = 4;
                            cell.BorderWidthTop = 0.2f;
                            cell.DisableBorderSide(2);
                            ptable.AddCell(cell);
                        }
                    }
                    ptable.WriteSelectedRows(0, -1, 10, 620, writer.DirectContent);

                }

                cb.EndText();
                document.Close();
                writer.Resume();

                Response.Clear();
                Response.Charset = "gb2312";
                Response.ContentEncoding = System.Text.Encoding.UTF8;
                // Response.AddHeader("Content-Disposition", "attach-ment;filename=" + System.Web.HttpUtility.UrlEncode(filename, System.Text.Encoding.UTF8) + ".pdf ");
                Response.AddHeader("Content-Disposition", "attach-ment;filename=" + filename);
                Response.WriteFile(newPDFName);
            }

        }
Exemplo n.º 7
0
        /// <summary>
        /// 订单出货明细
        /// </summary>
        public void GetOrderDetailsPDF()
        {
            string deliver_id = Request.Params["deliver_id"];
            _DeliverDetailMgr = new DeliverDetailMgr(mySqlConnectionString);
            DataTable orderdeliver = _DeliverDetailMgr.GetOrderDelivers(deliver_id);
            Dictionary<string, string> dicproduct_freight_set = new Dictionary<string, string> { { "1", "1" }, { "2", "2" }, { "3", "1" }, { "4", "2" }, { "5", "5" }, { "6", "5" } };
            BaseFont bfChinese = BaseFont.CreateFont("C:\\WINDOWS\\Fonts\\simsun.ttc,1", BaseFont.IDENTITY_H, BaseFont.NOT_EMBEDDED);
            iTextSharp.text.Font font = new iTextSharp.text.Font(bfChinese, 12, iTextSharp.text.Font.NORMAL, new iTextSharp.text.BaseColor(0, 0, 0));//黑

            string filename = "order_details_D" + deliver_id.PadLeft(8, '0') + ".pdf";
            Document document = new Document(PageSize.A4, (float)5, (float)5, (float)20, (float)0.5);
            string newPDFName = Server.MapPath(excelPath) + filename;
            PdfWriter writer = PdfWriter.GetInstance(document, new FileStream(newPDFName, FileMode.Create));
            document.Open();

            PdfContentByte cb = writer.DirectContent;

            if (orderdeliver.Rows.Count > 0)
            {
                #region 生成條形碼
                BarCode.Code128 _Code = new BarCode.Code128();
                _Code.ValueFont = new System.Drawing.Font("宋体", 20);
                System.Drawing.Bitmap imgTemp = _Code.GetCodeImage("D" + orderdeliver.Rows[0]["deliver_id"].ToString().PadLeft(8, '0'), BarCode.Code128.Encode.Code128A);
                imgTemp.Save(System.AppDomain.CurrentDomain.BaseDirectory + "\\ImportUserIOExcel\\" + "Code.gif", System.Drawing.Imaging.ImageFormat.Gif);
                iTextSharp.text.Image IMG = iTextSharp.text.Image.GetInstance(Server.MapPath("../ImportUserIOExcel/Code.gif"));
                IMG.ScaleToFit(200, 30);
                IMG.SetAbsolutePosition(345, 740);
                #endregion

                cb.BeginText();
                cb.SetFontAndSize(bfChinese, 20);
                cb.ShowTextAligned(PdfContentByte.ALIGN_LEFT, "吉甲地市集出貨明細", 30, 750, 0);
                //首購
                if (orderdeliver.Rows[0]["priority"].ToString() == "1")
                {
                    PdfPTable ot = new PdfPTable(1);
                    ot.SetTotalWidth(new float[] { 190 });
                    PdfPCell c = new PdfPCell(new Phrase("", font));
                    c.FixedHeight = 30;
                    c.BorderWidthBottom = 0.5f;
                    c.BorderWidthLeft = 0.5f;
                    c.BorderWidthRight = 0.5f;
                    c.BorderWidthTop = 0.5f;
                    ot.AddCell(c);
                    ot.WriteSelectedRows(0, -1, 29, 770, cb);
                }
                cb.AddImage(IMG);
                if (orderdeliver.Rows[0]["channel"].ToString() != "1")
                {
                    cb.ShowTextAligned(PdfContentByte.ALIGN_LEFT, orderdeliver.Rows[0]["channel_name_simple"].ToString(), 80, 700, 0);
                }
                if (orderdeliver.Rows[0]["retrieve_mode"].ToString() == "1")
                {
                    cb.ShowTextAligned(PdfContentByte.ALIGN_LEFT, "7-11取貨", 200, 700, 0);
                }
                cb.SetFontAndSize(bfChinese, 10);
                string freight_set = string.Empty;
                switch (orderdeliver.Rows[0]["freight_set"].ToString().Trim())
                {
                    case "1":
                        freight_set = "常溫";
                        break;
                    case "2":
                        freight_set = "冷凍";
                        break;
                    case "5":
                        freight_set = "冷藏";
                        break;
                }
                cb.ShowTextAligned(PdfContentByte.ALIGN_LEFT, freight_set, 345, 785, 0);
                string estimated_arrival_period = string.Empty;
                if (orderdeliver.Rows[0]["estimated_arrival_period"].ToString() != "0")
                {
                    switch (orderdeliver.Rows[0]["estimated_arrival_period"].ToString().Trim())
                    {
                        case "0":
                            estimated_arrival_period = "不限時";
                            break;
                        case "1":
                            estimated_arrival_period = "12:00以前";
                            break;
                        case "2":
                            estimated_arrival_period = "12:00-17:00";
                            break;
                        case "3":
                            estimated_arrival_period = "17:00-20:00";
                            break;
                    }

                    cb.ShowTextAligned(PdfContentByte.ALIGN_LEFT, estimated_arrival_period, 345, 773, 0);
                }

            }
            cb.SetFontAndSize(bfChinese, 10);
            //cb.SetTextMatrix(150,20);
            cb.ShowTextAligned(PdfContentByte.ALIGN_LEFT, "訂購人:", 10, 680, 0);
            cb.ShowTextAligned(PdfContentByte.ALIGN_LEFT, "收件人:", 200, 680, 0);
            cb.ShowTextAligned(PdfContentByte.ALIGN_LEFT, "付款單號:", 10, 660, 0);
            cb.ShowTextAligned(PdfContentByte.ALIGN_LEFT, "收件地址:", 200, 660, 0);
            cb.ShowTextAligned(PdfContentByte.ALIGN_LEFT, "訂購時間:", 10, 640, 0);
            cb.ShowTextAligned(PdfContentByte.ALIGN_LEFT, "聯絡電話:", 200, 640, 0);
            cb.ShowTextAligned(PdfContentByte.ALIGN_LEFT, "付款時間:", 10, 620, 0);
            cb.ShowTextAligned(PdfContentByte.ALIGN_LEFT, "假日可收貨:", 200, 620, 0);
            cb.ShowTextAligned(PdfContentByte.ALIGN_LEFT, "出貨備註:", 10, 600, 0);
            cb.ShowTextAligned(PdfContentByte.ALIGN_LEFT, "訂單明細:", 10, 580, 0);
            if (orderdeliver.Rows.Count > 0 && orderdeliver.Rows[0]["receivable"].ToString() != "0")
            {
                cb.ShowTextAligned(PdfContentByte.ALIGN_LEFT, "應收金額:" + orderdeliver.Rows[0]["receivable"].ToString(), 200, 580, 0);
            }

            string address = string.Empty;
            string deliver_note = string.Empty;
            if (orderdeliver.Rows.Count > 0)
            {
                cb.ShowTextAligned(PdfContentByte.ALIGN_LEFT, orderdeliver.Rows[0]["order_name"].ToString(), 65, 680, 0);
                cb.ShowTextAligned(PdfContentByte.ALIGN_LEFT, orderdeliver.Rows[0]["delivery_name"].ToString(), 250, 680, 0);
                cb.ShowTextAligned(PdfContentByte.ALIGN_LEFT, orderdeliver.Rows[0]["order_id"].ToString(), 65, 660, 0);
                address += CommonFunction.ZipAddress(orderdeliver.Rows[0]["delivery_zip"].ToString()) + orderdeliver.Rows[0]["delivery_address"].ToString();

                cb.ShowTextAligned(PdfContentByte.ALIGN_LEFT, address, 250, 660, 0);
                string order_createdate = orderdeliver.Rows[0]["order_createdate"].ToString() != "0" ? CommonFunction.GetNetTime(long.Parse(orderdeliver.Rows[0]["order_createdate"].ToString())).ToString("yyyy-MM-dd HH:mm:ss") : "";
                string money_collect_date = orderdeliver.Rows[0]["money_collect_date"].ToString() != "0" ? CommonFunction.GetNetTime(long.Parse(orderdeliver.Rows[0]["money_collect_date"].ToString())).ToString("yyyy-MM-dd HH:mm:ss") : "";
                cb.ShowTextAligned(PdfContentByte.ALIGN_LEFT, order_createdate, 65, 640, 0);
                cb.ShowTextAligned(PdfContentByte.ALIGN_LEFT, orderdeliver.Rows[0]["delivery_mobile"].ToString(), 250, 640, 0);
                cb.ShowTextAligned(PdfContentByte.ALIGN_LEFT, money_collect_date, 65, 620, 0);
                cb.ShowTextAligned(PdfContentByte.ALIGN_LEFT, orderdeliver.Rows[0]["holiday_deliver"].ToString() == "1" ? "可" : "不可", 260, 620, 0);
                cb.ShowTextAligned(PdfContentByte.ALIGN_LEFT, orderdeliver.Rows[0]["note_order"].ToString().Trim(), 65, 600, 0);
                if (orderdeliver.Rows[0]["delivery_store"].ToString() == "12")
                {
                    deliver_note = "*自取(取貨地址:台北市南港區八德路4段768巷7號6樓之1,取貨時間週一~週五,AM9:00~PM6:00)";
                }
                else if (orderdeliver.Rows[0]["delivery_store"].ToString() == "13")
                {
                    deliver_note = "*自取(取貨地址:新北市板橋區三民路二段33號21樓,取貨時間週一~週五,AM9:00~PM6:00)";
                }
                else if (orderdeliver.Rows[0]["delivery_store"].ToString() == "14")
                {
                    deliver_note = "*自取(取貨地址:新北市永和區成功路一段80號20樓,取貨時間週一~週五,AM9:00~PM6:00)";
                }
                cb.SetFontAndSize(bfChinese, 8);
                cb.ShowTextAligned(PdfContentByte.ALIGN_LEFT, deliver_note, 65, 580, 0);
            }
            cb.EndText();
            PdfPTable ptable = new PdfPTable(7);
            ptable.WidthPercentage = 98;
            ptable.SetTotalWidth(new float[] { 50, 280, 50, 50, 50, 50, 50 });
            PdfPCell cell;
            font = new iTextSharp.text.Font(bfChinese, 8, iTextSharp.text.Font.NORMAL, new iTextSharp.text.BaseColor(0, 0, 0));//黑
            cell = new PdfPCell(new Phrase("商品編號", font));
            cell.DisableBorderSide(2);
            cell.DisableBorderSide(8);
            ptable.AddCell(cell);
            cell = new PdfPCell(new Phrase("商品名稱", font));
            cell.DisableBorderSide(2);
            cell.DisableBorderSide(8);
            ptable.AddCell(cell);
            cell = new PdfPCell(new Phrase("托運單屬性", font));
            cell.DisableBorderSide(2);
            cell.DisableBorderSide(8);
            ptable.AddCell(cell);
            cell = new PdfPCell(new Phrase("數量", font));
            cell.DisableBorderSide(2);
            cell.DisableBorderSide(8);
            ptable.AddCell(cell);
            cell = new PdfPCell(new Phrase("本次出貨", font));
            cell.DisableBorderSide(2);
            cell.DisableBorderSide(8);
            ptable.AddCell(cell);
            cell = new PdfPCell(new Phrase("預計出貨日", font));
            cell.DisableBorderSide(2);
            cell.DisableBorderSide(8);
            ptable.AddCell(cell);
            cell = new PdfPCell(new Phrase("供應商自出", font));
            cell.DisableBorderSide(2);
            ptable.AddCell(cell);
            PdfPCell td;
            string lastdeliverid = "0";
            ArrayList normal = new ArrayList();
            ArrayList low = new ArrayList();
            ArrayList lowstore = new ArrayList();
            DataRow[] sinceorder = new DataRow[] { };

            DataRow[] singleproduct = new DataRow[] { };//單一商品
            DataRow[] fatherproduct = new DataRow[] { };//組合商品中的父商品
            DataRow[] sonproduct = new DataRow[] { };//組合商品中的子商品
            ArrayList combine = new ArrayList();
            List<DataRow[]> orderdelivers = new List<DataRow[]>();

            sinceorder = orderdeliver.Select("dtype=2 and combined_mode<=1 ", "item_id asc");//自出商品
            singleproduct = orderdeliver.Select("dtype <>2 and combined_mode<=1  ", "item_id asc");//單一商品
            if (singleproduct.Count() > 0)
            {
                orderdelivers.Add(singleproduct);
            }
            fatherproduct = orderdeliver.Select(" combined_mode>1 and item_mode=1", "item_id asc");//組合商品中父商品是否存在
            foreach (var item in fatherproduct)
            {
                combine.Add(item);
                sonproduct = orderdeliver.Select(" combined_mode>1 and item_mode<>1 and parent_id=" + item["parent_id"] + " and pack_id=" + item["pack_id"], "item_id asc");//對應組合商品中的子商品
                foreach (var son in sonproduct)
                {
                    son["buy_num"] = (int.Parse(son["buy_num"].ToString()) * int.Parse(son["parent_num"].ToString())).ToString();
                    combine.Add(son);
                }
            }
            if (combine.Count > 0)
            {
                orderdelivers.Add((DataRow[])combine.ToArray(typeof(DataRow)));
            }
            //區分常溫、冷凍、冷藏
            foreach (var item in orderdelivers)
            {
                foreach (var row in item)
                {
                    string s = row["product_freight_set"].ToString();
                    switch (row["product_freight_set"].ToString())
                    {
                        case "1":
                        case "3":
                            normal.Add(row);//常溫
                            break;
                        case "2":
                        case "4":
                            low.Add(row);//冷凍
                            break;
                        case "5":
                        case "6":
                            lowstore.Add(row);//冷藏
                            break;
                        default:
                            break;
                    }
                }
            }

            orderdelivers = new List<DataRow[]>();
            if (normal.Count > 0)
            {
                orderdelivers.Add((DataRow[])normal.ToArray(typeof(DataRow)));
            }
            if (low.Count > 0)
            {
                orderdelivers.Add((DataRow[])low.ToArray(typeof(DataRow)));
            }
            if (lowstore.Count > 0)
            {
                orderdelivers.Add((DataRow[])lowstore.ToArray(typeof(DataRow)));
            }
            if (sinceorder.Count() > 0)
            {
                orderdelivers.Add(sinceorder);
            }
            int j = 0;
            foreach (var item in orderdelivers)
            {
                j++;
                for (int i = 0; i < item.Count(); i++)
                {
                    if (item[i]["ddeliver_id"].ToString() != lastdeliverid || i == 0)
                    {
                        lastdeliverid = item[i]["ddeliver_id"].ToString();//以一個出貨單號為界限
                        if (lastdeliverid != "0" || i == 0)
                        {
                            td = new PdfPCell();
                            td.Colspan = 7;
                            td.DisableBorderSide(2);
                            td.DisableBorderSide(4);
                            td.DisableBorderSide(8);
                            //td.BorderWidthTop = 0.2f;
                            ptable.AddCell(td);
                        }
                    }
                    string item_id = string.Empty;
                    if (item[i]["item_mode"].ToString() == "1")
                    {
                        item_id = item[i]["parent_id"].ToString();
                    }
                    else
                    {
                        item_id = item[i]["item_id"].ToString();
                    }
                    font = new iTextSharp.text.Font(bfChinese, 8, iTextSharp.text.Font.NORMAL, new iTextSharp.text.BaseColor(0, 0, 0));//黑
                    td = new PdfPCell(new Phrase(item_id, font));
                    td.DisableBorderSide(1);
                    td.DisableBorderSide(2);
                    td.DisableBorderSide(8);
                    //td.BorderWidthLeft = 0.2f;
                    ptable.AddCell(td);
                    string datacontent = ((item[i]["product_mode"].ToString() == "2" && item[i]["item_mode"].ToString() != "1") ? "*" : " ") + item[i]["brand_name"].ToString() + "-" + item[i]["product_name"].ToString() + item[i]["product_spec_name"].ToString();
                    if (item[i]["combined_mode"].ToString() != "0" && item[i]["item_mode"].ToString() == "2")
                    {
                        datacontent = "  " + datacontent;
                    }
                    td = new PdfPCell(new Phrase(datacontent, font));
                    td.DisableBorderSide(1);
                    td.DisableBorderSide(2);
                    td.DisableBorderSide(8);
                    ptable.AddCell(td);
                    string value = string.Empty;
                    string freight_set = string.Empty;
                    if (dicproduct_freight_set.TryGetValue(item[i]["product_freight_set"].ToString(), out value))
                    {

                    }
                    switch (value)
                    {
                        case "1":
                            freight_set = "常溫";
                            break;
                        case "2":
                            freight_set = "冷凍";
                            break;
                        case "5":
                            freight_set = "冷藏";
                            break;
                    }
                    td = new PdfPCell(new Phrase(freight_set, font));
                    td.DisableBorderSide(1);
                    td.DisableBorderSide(2);
                    td.DisableBorderSide(8);
                    //td.BorderWidthLeft = 0.2f;
                    ptable.AddCell(td);
                    font = new iTextSharp.text.Font(bfChinese, 10, iTextSharp.text.Font.NORMAL, new iTextSharp.text.BaseColor(0, 0, 0));//黑
                    td = new PdfPCell(new Phrase(item[i]["item_mode"].ToString() != "1" ? item[i]["buy_num"].ToString() : "", font));
                    td.DisableBorderSide(1);
                    td.DisableBorderSide(2);
                    td.DisableBorderSide(8);
                    // td.BorderWidthLeft = 0.2f;
                    ptable.AddCell(td);
                    td = new PdfPCell();
                    td.DisableBorderSide(1);
                    td.DisableBorderSide(2);
                    td.DisableBorderSide(8);
                    //td.BorderWidthLeft = 0.2f;
                    ptable.AddCell(td);
                    td = new PdfPCell();
                    td.DisableBorderSide(1);
                    td.DisableBorderSide(2);
                    td.DisableBorderSide(8);
                    //td.BorderWidthLeft = 0.2f;
                    ptable.AddCell(td);

                    Image image = Image.GetInstance(Server.MapPath("../Content/img/icons/mark.png"));
                    image.ScalePercent(5, 5);
                    if (item[i]["dtype"].ToString() == "2")
                    {
                        td = new PdfPCell(image, false);
                    }
                    else
                    {
                        td = new PdfPCell();
                    }
                    td.HorizontalAlignment = Element.ALIGN_CENTER;
                    td.VerticalAlignment = Element.ALIGN_MIDDLE;
                    td.DisableBorderSide(1);
                    td.DisableBorderSide(2);
                    ptable.AddCell(td);
                }
            }
            string note_order = orderdeliver.Rows.Count.ToString() != "0" ? orderdeliver.Rows[0]["note_order"].ToString().Trim() : "";
            cell = new PdfPCell(new Phrase(new Chunk("備註:" + note_order, font)));
            cell.Colspan = 7;
            cell.HorizontalAlignment = Element.ALIGN_LEFT;
            ptable.AddCell(cell);
            PdfPTable nulltable = new PdfPTable(2);
            nulltable.SetWidths(new int[] { 20, 20 });
            nulltable.DefaultCell.DisableBorderSide(1);
            nulltable.DefaultCell.DisableBorderSide(2);
            nulltable.DefaultCell.DisableBorderSide(4);
            nulltable.DefaultCell.DisableBorderSide(8);
            nulltable.AddCell("");
            nulltable.AddCell("");
            nulltable.SpacingAfter = 250;
            document.Add(nulltable);
            ptable.SpacingAfter = 50;
            document.Add(ptable);

            font = new iTextSharp.text.Font(bfChinese, 10, iTextSharp.text.Font.NORMAL, new iTextSharp.text.BaseColor(0, 0, 0));//黑
            document.Add(new Phrase("吉甲地市集網路平台購物發票說明:\n", font));
            font = new iTextSharp.text.Font(bfChinese, 8, iTextSharp.text.Font.NORMAL, new iTextSharp.text.BaseColor(0, 0, 0));//黑
            document.Add(new Phrase("若您訂購時未選擇開立三聯式發票,平台一律開立電子發票。\n", font));
            document.Add(new Phrase("發票將於該筆訂單商品完全出貨之後第10天開立並以E-Mail通知您。\n", font));
            document.Add(new Phrase("如需紙本發票請來信客服中心,會計部門將會依需求將電子發票印出並以平信郵寄約2~7個工作天內送達。\n", font));
            document.Add(new Phrase("託管發票將會在單月26日進行對獎作業後,系統將會發信通知中獎發票持有人,\n", font));
            document.Add(new Phrase("且為保障您的權益,我們將在七個工作天內,以掛號方式把中獎發票寄給您。\n", font));
            font = new iTextSharp.text.Font(bfChinese, 10, iTextSharp.text.Font.NORMAL, new iTextSharp.text.BaseColor(0, 0, 0));//黑
            document.Add(new Phrase("祝您購物愉快!", font));
            document.Close();
            writer.Resume();

            Response.Clear();
            Response.Charset = "gb2312";
            Response.ContentEncoding = System.Text.Encoding.UTF8;
            Response.AddHeader("Content-Disposition", "attach-ment;filename=" + filename);
            Response.WriteFile(newPDFName);
        }
        /// <summary>
        /// 根据时间段转化为相应的时间查找条件
        /// </summary>
        /// <param name="rows"></param>
        /// <param name="date"></param>
        /// <returns></returns>
        private string ConvertToSqlStr(DataRow[] rows, string date, string workingTeam="")
        {
            StringBuilder timeBuilder = new StringBuilder();
            int n = rows.Count();
            //SqlParameter paramater = new SqlParameter("variableName", variableName);
            foreach (DataRow dr in rows)
            {
                string endTime;
                string startTime;
                if ("24:00" == dr["EndTime"].ToString().Trim())
                {
                    DateTime time= DateTime.Parse(date + " 00:00:00");
                    endTime= time.AddDays(1).ToString();
                    //endTime = "23:59:59";
                }
                else
                {
                    endTime =date+" "+ dr["EndTime"].ToString().Trim() + ":00";

                }
                startTime = date + " " + dr["StartTime"].ToString().Trim() + ":00";
                if (workingTeam == "甲班" && DateTime.Parse(startTime)>DateTime.Parse(endTime))
                {
                    startTime = DateTime.Parse(startTime).AddDays(-1).ToString();
                }
               if (workingTeam == "丙班" && DateTime.Parse(startTime) > DateTime.Parse(endTime))
                {
                    endTime = DateTime.Parse(endTime).AddDays(1).ToString();
                }
                timeBuilder.Append("vDate>=");
                //timeBuilder.Append("#");
                timeBuilder.Append("'");
                timeBuilder.Append(startTime);
                //timeBuilder.Append(dr["StartTime"].ToString().Trim() + ":00");
                //timeBuilder.Append("#");
                timeBuilder.Append("'");
                timeBuilder.Append(" AND ");
                timeBuilder.Append("vDate<");
                //timeBuilder.Append("#");
                timeBuilder.Append("'");
                //timeBuilder.Append(date + " ");
                timeBuilder.Append(endTime);
                //timeBuilder.Append("#");
                timeBuilder.Append("'");
                timeBuilder.Append(" OR ");
            }
            int m_long = timeBuilder.ToString().Length;
            string timeCriterion = timeBuilder.ToString().Substring(0, m_long - 4);
            return timeCriterion;
        }
Exemplo n.º 9
0
        /// <summary>
        /// 新增待办
        /// </summary>
        /// <param name="entity"></param>
        /// <param name="dr1"></param>
        /// <param name="SourceValueDT"></param>
        /// <param name="strAPPFIELDVALUE"></param>
        public void AddDoTask(T_WF_DOTASK entity, DataRow[] drs, DataTable SourceValueDT, string strAPPFIELDVALUE, string submitUserName, string ModeName, string applicationUrl)
        {
            CloseDoTaskStatus(entity.SYSTEMCODE, entity.ORDERID, null);
            try
            {
                string[] strListUser;
                if (entity.RECEIVEUSERID.IndexOf('|') != -1)
                {
                    strListUser = entity.RECEIVEUSERID.ToString().Split('|');
                }
                else
                {
                    strListUser = new string[1];
                    strListUser[0] = entity.RECEIVEUSERID.ToString();
                }
                //
                foreach (string User in strListUser)
                {
                    string insSql = @"INSERT INTO T_WF_DOTASK (DOTASKID,COMPANYID,ORDERID,ORDERUSERID,ORDERUSERNAME,ORDERSTATUS,MESSAGEBODY,
                                     APPLICATIONURL,RECEIVEUSERID,BEFOREPROCESSDATE,DOTASKTYPE,DOTASKSTATUS,MAILSTATUS,
                                     RTXSTATUS,APPFIELDVALUE,FLOWXML,APPXML,SYSTEMCODE,MODELCODE,MODELNAME,REMARK)
                                     VALUES (@DOTASKID,@COMPANYID,@ORDERID,@ORDERUSERID,@ORDERUSERNAME,@ORDERSTATUS,@MESSAGEBODY,@APPLICATIONURL,
                                    @RECEIVEUSERID,@BEFOREPROCESSDATE,@DOTASKTYPE,@DOTASKSTATUS,@MAILSTATUS,@RTXSTATUS,
                                    @APPFIELDVALUE,@FLOWXML,@APPXML,@SYSTEMCODE,@MODELCODE,@MODELNAME,@REMARK)";
                    Parameter[] pageparm =
                        {
                            new Parameter("@DOTASKID",null),
                            new Parameter("@COMPANYID",null),
                            new Parameter("@ORDERID",null),
                            new Parameter("@ORDERUSERID",null),
                            new Parameter("@ORDERUSERNAME",null),
                            new Parameter("@ORDERSTATUS",null),
                            new Parameter("@MESSAGEBODY",null),
                            new Parameter("@APPLICATIONURL",null),
                            new Parameter("@RECEIVEUSERID",null),
                            new Parameter("@BEFOREPROCESSDATE",null),
                            new Parameter("@DOTASKTYPE",null),
                            new Parameter("@DOTASKSTATUS",null),
                            new Parameter("@MAILSTATUS",null),
                            new Parameter("@RTXSTATUS",null),
                            new Parameter("@APPFIELDVALUE",null),
                            new Parameter("@FLOWXML",null),
                            new Parameter("@APPXML",null),
                            new Parameter("@SYSTEMCODE",null),
                            new Parameter("@MODELCODE",null),
                            new Parameter("@MODELNAME",null),
                            new Parameter("@REMARK",null)
                        };
                    pageparm[0].ParameterValue = GetValue(Guid.NewGuid().ToString());//待办任务ID
                    pageparm[1].ParameterValue = GetValue(entity.COMPANYID);//公司ID
                    pageparm[2].ParameterValue = GetValue(entity.ORDERID);//单据ID
                    pageparm[3].ParameterValue = GetValue(entity.ORDERUSERID);//单据所属人ID
                    pageparm[4].ParameterValue = GetValue(entity.ORDERUSERNAME);//单据所属人名称
                    pageparm[5].ParameterValue = GetValue(entity.ORDERSTATUS);//单据状态

                    if (SourceValueDT != null)
                    {
                        foreach (DataRow dr in SourceValueDT.Rows)
                        {
                            if (!string.IsNullOrEmpty(dr["ColumnValue"].ToString().Trim()))
                            {
                                if (dr["ColumnName"].ToString().ToLower() == "appusername")
                                {
                                    string AppUserName = dr["ColumnValue"].ToString();
                                    pageparm[20].ParameterValue = AppUserName;//接收员工名,使用remark字段
                                }
                            }
                        }
                    }
                    #region 消息体
                    string XmlTemplete = "<?xml version=\"1.0\" encoding=\"utf-8\" ?>" + "\r\n" +
                                  "<System>" + "\r\n" +
                                  "{0}" +
                                  "</System>";

                    string strMsgBody = string.Empty;
                    string strMsgUrl = applicationUrl;
                    if (drs.Count() == 0)//如果没有设置消息,则构造默认消息:请审核xxx提交的"xxxx",
                    {
                        strMsgBody = "请审核[" + submitUserName + @"]提交的[" + ModeName + "]";
                        pageparm[6].ParameterValue = strMsgBody;//消息体
                        pageparm[7].ParameterValue = ReplaceLowerValue(strMsgUrl, SourceValueDT);//应用URL
                    }
                    else
                    {
                        DataRow dr1 = drs[0];
                        if (dr1["MESSAGEBODY"].ToString() == "")//默认消息为空
                        {
                            if (dr1 != null)
                            {
                                ModelMsgDefine(dr1["SYSTEMCODE"].ToString(), dr1["MODELCODE"].ToString(), entity.COMPANYID, ref strMsgBody, ref strMsgUrl);
                            }
                            if (string.IsNullOrEmpty(strMsgBody))
                            {
                                try
                                {
                                    DataRow[] drvList = SourceValueDT.Select("ColumnName='ModelName'");
                                    if (drvList.Count() == 1)
                                    {
                                        string value = drvList[0]["ColumnValue"].ToString();
                                        if (string.IsNullOrWhiteSpace(value))
                                        {
                                            value = drvList[0]["ColumnText"].ToString();
                                        }
                                        pageparm[6].ParameterValue = GetValue(value + "已审批通过");//消息体
                                    }
                                    else
                                    {
                                        pageparm[6].ParameterValue = GetValue(entity.ORDERID + "已审批通过");//消息体

                                    }
                                }
                                catch { }

                            }
                            else
                            {
                                pageparm[6].ParameterValue = GetValue(ReplaceMessageBody(strMsgBody, SourceValueDT));//消息体
                            }
                            string strUrl = string.Format(XmlTemplete, ReplaceValue(strMsgUrl, SourceValueDT));
                            Tracer.Debug("查询到得消息链接:" + strUrl + "单据ID:" + entity.ORDERID);
                            pageparm[7].ParameterValue = GetValue(strUrl);//应用URL
                        }
                        else//在引擎配置界面定义了消息内容
                        {
                            Tracer.Debug("Formid=" + entity.ORDERID + "开始 待办消息体:" + dr1["MESSAGEBODY"].ToString() + "\n\r 开始 打开待办连接的参数:" + dr1["APPLICATIONURL"].ToString());
                            string rowsValues = "Formid=" + entity.ORDERID + "\r\n";//每一行的值
                            for (int j = 0; j < SourceValueDT.Rows.Count; j++)
                            {
                                for (int i = 0; i < SourceValueDT.Columns.Count; i++)
                                {
                                    string columnName = SourceValueDT.Columns[i].ColumnName;
                                    rowsValues += columnName + "=" + SourceValueDT.Rows[j][columnName].ToString() + ";";
                                }
                                rowsValues += "\r\n";
                            }
                            Tracer.Debug("SourceValueDT表数据:" + rowsValues);
                            pageparm[6].ParameterValue = GetValue(ReplaceMessageBody(dr1["MESSAGEBODY"].ToString(), SourceValueDT));//消息体
                            pageparm[7].ParameterValue = GetValue(string.Format(XmlTemplete, ReplaceValue(dr1["APPLICATIONURL"].ToString(), SourceValueDT)));//应用URL
                            Tracer.Debug("Formid=" + entity.ORDERID + "最后 待办消息体:" + pageparm[6].ParameterValue + "\n\r 最后 打开待办连接的参数:" + pageparm[7].ParameterValue);
                        }
                    }
                    #endregion
                    pageparm[8].ParameterValue = GetValue(User);// GetValue(entity.RECEIVEUSERID);//接收用户ID
                    if (entity.BEFOREPROCESSDATE != null)//流程过期时间属性
                    {
                        //sql += "to_date('" + entity.BEFOREPROCESSDATE + "','YYYY-MM-DD hh24:mi:ss')";
                        pageparm[9].ParameterValue = GetValue(entity.BEFOREPROCESSDATE);//可处理时间(主要针对KPI考核)
                    }
                    else
                    {
                        if (drs.Count() > 0)//如果没有设置消息,则构造默认消息:请审核xxx提交的"xxxx",
                        {
                            DataRow dr1 = drs[0];
                            if (dr1["LASTDAYS"] != null)
                            {
                                if (string.IsNullOrEmpty(dr1["LASTDAYS"].ToString()))
                                {
                                    pageparm[9].ParameterValue = GetValue(DateTime.Now.AddDays(3));//可处理时间(主要针对KPI考核)
                                }
                                else
                                {
                                    pageparm[9].ParameterValue = GetValue(DateTime.Now.AddDays(int.Parse(dr1["LASTDAYS"].ToString())));//可处理时间(主要针对KPI考核)
                                }
                            }
                            else
                            {
                                pageparm[9].ParameterValue = GetValue(DateTime.Now.AddDays(3));
                            }
                        }
                    }
                    pageparm[10].ParameterValue = GetValue(0);//待办任务类型(0、待办任务、1、流程咨询、3 )
                    pageparm[11].ParameterValue = GetValue(0);//代办任务状态(0、未处理 1、已处理 、2、任务撤销 10、删除)
                    pageparm[12].ParameterValue = GetValue(0);//邮件状态(0、未发送 1、已发送、2、未知 )
                    pageparm[13].ParameterValue = GetValue(0);//RTX状态(0、未发送 1、已发送、2、未知 )
                    pageparm[14].ParameterValue = GetValue(strAPPFIELDVALUE);//应用字段值
                    pageparm[15].ParameterValue = GetValue(entity.FLOWXML);//流程XML
                    pageparm[16].ParameterValue = GetValue(entity.APPXML);//应用XML
                    pageparm[17].ParameterValue = GetValue(entity.SYSTEMCODE);//系统代码
                    pageparm[18].ParameterValue = GetValue(entity.MODELCODE);//模块代码
                    pageparm[19].ParameterValue = GetValue(entity.MODELNAME);//模块名称
                    //DataRow[] ModelCodeList = SourceValueDT.Select("ColumnName='ModelCode'");
                    //if (ModelCodeList.Count() == 1)
                    //{
                    //    sql += "'" + ModelCodeList[0]["ColumnValue"].ToString() + "')";
                    //}
                    //else
                    //{
                    //    sql += "'')";
                    //}
                    int result = dao.ExecuteNonQuery(insSql, pageparm);
                    if (result > 0)
                    {
                        Tracer.Debug("A新增待办任务AddDoTask (成功)  FormID=" + entity.ORDERID + " 接收人ID=" + User);
                    }
                    else
                    {
                        Tracer.Debug("A新增待办任务AddDoTask (失败)  FormID=" + entity.ORDERID + " 接收人ID=" + User);
                    }
                }

            }
            catch (Exception ex)
            {
                Tracer.Debug("A新增待办任AddDoTask (失败) FormID=" + entity.ORDERID + " 命名空间: SMT.FlowDAL.EnginFlowDAL 类方法:AddDoTask()" + ex.Message);
                throw new Exception("新增待办任失败 FormID=" + entity.ORDERID);
            }
        }