Exemplo n.º 1
0
 public List<CbjobMasterQuery> GetjobMaster(CbjobMasterQuery m, out int totalCount)
 {
     try
     {
         return _cbjobDao.GetjobMaster(m, out totalCount);
     }
     catch (Exception ex)
     {
         throw new Exception("CbjobMasterMgr-->GetjobMaster-->" + ex.Message, ex);
     }
 }
Exemplo n.º 2
0
 public List<CbjobMasterQuery> GetjobMaster(CbjobMasterQuery m, out int totalCount)
 {
     StringBuilder sbclumn=new StringBuilder();
     StringBuilder sqlCondi = new StringBuilder();
     totalCount = 0;
     try
     {
         sbclumn.Append(" select cm.row_id,cm.cbjob_id,cm.create_datetime,cm.status,cm.create_user,cm.sta_id ");
         sqlCondi.Append(" from cbjob_master cm where 1=1 ");
         if (!string.IsNullOrEmpty(m.startDate))
         {
             sqlCondi.AppendFormat(" and cm.create_datetime>='{0}' ", m.startDate);
         }
         if (!string.IsNullOrEmpty(m.endDate))
         {
             sqlCondi.AppendFormat(" and cm.create_datetime<='{0}' ", m.endDate);
         }
         if (!string.IsNullOrEmpty(m.cbjob_id))
         {
             sqlCondi.AppendFormat(" and cm.cbjob_id like'{0}' ", m.cbjob_id);
         }
         if (!string.IsNullOrEmpty(m.sta_id))
         {
             sqlCondi.AppendFormat(" and cm.sta_id = '{0}' ", m.sta_id);
         }
         if (!string.IsNullOrEmpty(m.row_id_IN))
         {
             sqlCondi.AppendFormat(" and cm.row_id in ({0}) ", m.row_id_IN);
         }
         if (m.IsPage)
         {
             System.Data.DataTable _dt = _accessMySql.getDataTable("select count(cm.row_id) as totalCount " + sqlCondi.ToString());
             if (_dt != null && _dt.Rows.Count > 0)
             {
                 totalCount = int.Parse(_dt.Rows[0]["totalCount"].ToString());
             }
             sqlCondi.AppendFormat(" limit {0},{1}", m.Start, m.Limit);
         }
         return _accessMySql.getDataTableForObj<CbjobMasterQuery>(sbclumn .ToString()+ sqlCondi.ToString());
     }
     catch (Exception ex)
     {
         throw new Exception("CbjobMasterDao-->GetjobMaster-->" + ex.Message + sbclumn.ToString() + sqlCondi.ToString(), ex);
     }
    
 }
Exemplo n.º 3
0
        /// <summary>
        /// 匯出盤點工作PDF
        /// </summary>
        public void CountBookPDF()
        {
            PdfHelper pdf = new PdfHelper();
            List<string> pdfList = new List<string>();
            float[] arrColWidth = new float[] { 25, 60, 40, 40, 55,40, 140, 50, 40, 50};
            string newFileName = string.Empty;
            string newName = string.Empty;
            string json = string.Empty;
            BaseFont bf = BaseFont.CreateFont("C:\\WINDOWS\\Fonts\\simsun.ttc,1", BaseFont.IDENTITY_H, BaseFont.NOT_EMBEDDED);
            iTextSharp.text.Font fontChinese = new iTextSharp.text.Font(bf, 8, iTextSharp.text.Font.UNDERLINE, iTextSharp.text.BaseColor.RED);
            iTextSharp.text.Font font = new iTextSharp.text.Font(bf, 12, iTextSharp.text.Font.BOLD, new iTextSharp.text.BaseColor(0, 0, 0));//黑  
            string filename = "盤點工作" + DateTime.Now.ToString("yyyyMMddHHmmss");
            Document document = new Document(PageSize.A4.Rotate());
            string newPDFName = Server.MapPath(excelPath) + filename;
            PdfWriter writer = PdfWriter.GetInstance(document, new FileStream(newPDFName, FileMode.Create));
            document.Open();
            int index = 0;
            CbjobMasterQuery query = new CbjobMasterQuery();
            List<CbjobMasterQuery> cbjobList = new List<CbjobMasterQuery>();
            query.IsPage = false;

            if (!string.IsNullOrEmpty(Request.Params["rowIDs"]))
            {
                query.row_id_IN = Request.Params["rowIDs"].TrimEnd(',');

            }
            _CbjobMasterMgr = new CbjobMasterMgr(mySqlConnectionString);
            int totalCount = 0;
            cbjobList = _CbjobMasterMgr.GetjobMaster(query, out  totalCount);
            DataTable _dtBody = new DataTable();
            _dtBody.Columns.Add("編號", typeof(string));
            _dtBody.Columns.Add("條碼", typeof(string));
            _dtBody.Columns.Add("料位", typeof(string));
            _dtBody.Columns.Add("現有庫存", typeof(string));
            _dtBody.Columns.Add("盤點數量", typeof(string));
            _dtBody.Columns.Add("效期控制", typeof(string));
            _dtBody.Columns.Add("品名", typeof(string));
            _dtBody.Columns.Add("規格", typeof(string));
            _dtBody.Columns.Add("細項編號", typeof(string));
            _dtBody.Columns.Add("備註", typeof(string));
            PdfPTable ptablefoot = new PdfPTable(10);

                if (cbjobList.Count > 0)
                {
                    _cbjobMgr = new CbjobDetailMgr(mySqlConnectionString);


                    for (int i = 0; i < cbjobList.Count; i++)
                    {
                        CbjobDetail cbdetail = new CbjobDetail();
                        cbdetail.cb_jobid = cbjobList[i].cbjob_id;
                        DataTable _dtdetail = _cbjobMgr.GetDetailTable(cbdetail);
                        _dtBody.Rows.Clear();


                        #region 標頭
                        #region 標頭
                        PdfPTable ptable = new PdfPTable(10);
                        ptable.WidthPercentage = 100;//表格寬度
                        ptable.SetTotalWidth(arrColWidth);
                        PdfPCell cell = new PdfPCell();
                        cell = new PdfPCell(new Phrase("", new iTextSharp.text.Font(bf, 12)));
                        cell.VerticalAlignment = Element.ALIGN_LEFT;//字體水平居左
                        cell.Colspan = 10;
                        cell.DisableBorderSide(1);
                        cell.DisableBorderSide(4);
                        cell.DisableBorderSide(8);
                        ptable.AddCell(cell);

                        cell = new PdfPCell(new Phrase("", new iTextSharp.text.Font(bf, 12)));
                        cell.VerticalAlignment = Element.ALIGN_LEFT;//字體水平居左
                        cell.Colspan = 4;
                        cell.DisableBorderSide(1);
                        cell.DisableBorderSide(2);
                        // cell.DisableBorderSide(4);
                        cell.DisableBorderSide(8);
                        ptable.AddCell(cell);

                        cell = new PdfPCell(new Phrase("      盤點薄" + "-" + cbdetail.cb_jobid, new iTextSharp.text.Font(bf, 18)));
                        cell.VerticalAlignment = Element.ALIGN_LEFT;
                        cell.Colspan = 3;
                        cell.DisableBorderSide(1);
                        cell.DisableBorderSide(2);
                        cell.DisableBorderSide(4);
                        cell.DisableBorderSide(8);
                        ptable.AddCell(cell);

                        cell = new PdfPCell(new Phrase("", new iTextSharp.text.Font(bf, 12)));
                        cell.VerticalAlignment = Element.ALIGN_LEFT;//字體水平居左
                        cell.Colspan = 3;
                        cell.DisableBorderSide(1);
                        cell.DisableBorderSide(2);
                        cell.DisableBorderSide(4);
                        // cell.DisableBorderSide(8);
                        ptable.AddCell(cell);

                        cell = new PdfPCell(new Phrase("", new iTextSharp.text.Font(bf, 12)));
                        cell.VerticalAlignment = Element.ALIGN_LEFT;//字體水平居左
                        cell.Colspan = 10;
                        cell.DisableBorderSide(1);
                        cell.DisableBorderSide(2);
                        // cell.DisableBorderSide(4);
                        //cell.DisableBorderSide(8);
                        ptable.AddCell(cell);


                        #endregion
                        #region 表頭
                        cell = new PdfPCell(new Phrase("編號", new iTextSharp.text.Font(bf, 12)));
                        cell.VerticalAlignment = Element.ALIGN_LEFT;//字體水平居左
                        cell.DisableBorderSide(8);
                        ptable.AddCell(cell);

                        cell = new PdfPCell(new Phrase("條碼", new iTextSharp.text.Font(bf, 12)));
                        cell.VerticalAlignment = Element.ALIGN_LEFT;//字體水平居左
                        cell.DisableBorderSide(8);
                        ptable.AddCell(cell);



                        cell = new PdfPCell(new Phrase("料位", new iTextSharp.text.Font(bf, 12)));
                        cell.VerticalAlignment = Element.ALIGN_LEFT;//字體水平居左
                        cell.DisableBorderSide(8);
                        ptable.AddCell(cell);

                        cell = new PdfPCell(new Phrase("現有庫存", new iTextSharp.text.Font(bf, 12)));
                        cell.VerticalAlignment = Element.ALIGN_LEFT;//字體水平居左
                        cell.DisableBorderSide(8);
                        ptable.AddCell(cell);

                        cell = new PdfPCell(new Phrase("盤點數量", new iTextSharp.text.Font(bf, 12)));
                        cell.VerticalAlignment = Element.ALIGN_LEFT;//字體水平居左
                        cell.DisableBorderSide(8);
                        ptable.AddCell(cell);
                        cell = new PdfPCell(new Phrase("效期控制", new iTextSharp.text.Font(bf, 12)));
                        cell.VerticalAlignment = Element.ALIGN_LEFT;//字體水平居左
                        cell.DisableBorderSide(8);
                        ptable.AddCell(cell);
                        cell = new PdfPCell(new Phrase("品名", new iTextSharp.text.Font(bf, 12)));
                        cell.VerticalAlignment = Element.ALIGN_LEFT;//字體水平居左
                        cell.DisableBorderSide(8);
                        ptable.AddCell(cell);

                        cell = new PdfPCell(new Phrase("規格", new iTextSharp.text.Font(bf, 12)));
                        cell.VerticalAlignment = Element.ALIGN_LEFT;//字體水平居左
                        cell.DisableBorderSide(8);
                        ptable.AddCell(cell);
                        cell = new PdfPCell(new Phrase("細項編號", new iTextSharp.text.Font(bf, 12)));
                        cell.VerticalAlignment = Element.ALIGN_LEFT;//字體水平居左
                        cell.DisableBorderSide(8);
                        ptable.AddCell(cell);
                        cell = new PdfPCell(new Phrase("備註", new iTextSharp.text.Font(bf, 12)));
                        cell.VerticalAlignment = Element.ALIGN_LEFT;//字體水平居左
                        ptable.AddCell(cell);
                        #endregion
                        #endregion

                        if (_dtdetail.Rows.Count > 0)
                        {
                            _IiupcMgr = new IupcMgr(mySqlConnectionString);
                            int a = 0;
                            foreach (DataRow rows in _dtdetail.Rows)
                            {
                                a++;
                                string upc_id = string.Empty;
                                #region 取條碼

                                List<IupcQuery> list = new List<IupcQuery>();
                                IupcQuery iupc_query = new IupcQuery();
                                if (!string.IsNullOrEmpty(rows["item_id"].ToString()))
                                {
                                    uint item_id = uint.Parse(rows["item_id"].ToString());
                                    iupc_query.item_id = item_id;
                                    iupc_query.upc_type_flg = "1";
                                    list = _IiupcMgr.GetIupcByType(iupc_query);
                                    if (list.Count > 0)
                                    {
                                        upc_id = list[0].upc_id;
                                    }
                                    else
                                    {
                                        iupc_query.upc_type_flg = "3";
                                        list = _IiupcMgr.GetIupcByType(iupc_query);
                                        if (list.Count > 0)
                                        {
                                            upc_id = list[0].upc_id;
                                        }
                                        else
                                        {
                                            iupc_query.upc_type_flg = "2";
                                            list = _IiupcMgr.GetIupcByType(iupc_query);
                                            if (list.Count > 0)
                                            {
                                                upc_id = list[0].upc_id;
                                            }
                                        }
                                    }
                                }
                                else
                                {
                                    upc_id = " ";
                                }
                                #endregion
                                DataRow row = _dtBody.NewRow();
                                row["編號"] = a;
                                row["條碼"] = upc_id;

                                row["料位"] = rows["loc_id"];
                                row["現有庫存"] = rows["prod_qty"];
                                row["盤點數量"] = "";
                                row["效期控制"] = string.IsNullOrEmpty(rows["pwy_dte_ctl"].ToString()) ? "否" : (rows["pwy_dte_ctl"].ToString() == "Y" ? "是" : "否");
                                row["品名"] = rows["product_name"];
                                row["規格"] = rows["spec_title_1"];
                                row["細項編號"] = rows["item_id"];
                                row["備註"] = " ";
                                _dtBody.Rows.Add(row);
                            }
                        }
                        newFileName = newPDFName + "_part" + index++ + "." + "pdf";
                        pdf.ExportDataTableToPDF(_dtBody, false, newFileName, arrColWidth, ptable, ptablefoot, "", "", 10, uint.Parse(_dtBody.Rows.Count.ToString()));/*第一7是列,第二個是行*/
                        pdfList.Add(newFileName);
                    }



                }
            if (_dtBody.Rows.Count == 0)
            {
                #region 標頭
                #region 標頭
                PdfPTable ptable = new PdfPTable(10);
                ptable.WidthPercentage = 100;//表格寬度
                ptable.SetTotalWidth(arrColWidth);
                PdfPCell cell = new PdfPCell();
                cell = new PdfPCell(new Phrase("", new iTextSharp.text.Font(bf, 12)));
                cell.VerticalAlignment = Element.ALIGN_LEFT;//字體水平居左
                cell.Colspan = 10;
                cell.DisableBorderSide(1);
                cell.DisableBorderSide(4);
                cell.DisableBorderSide(8);
                ptable.AddCell(cell);

                cell = new PdfPCell(new Phrase("", new iTextSharp.text.Font(bf, 12)));
                cell.VerticalAlignment = Element.ALIGN_LEFT;//字體水平居左
                cell.Colspan = 4;
                cell.DisableBorderSide(1);
                cell.DisableBorderSide(2);
                // cell.DisableBorderSide(4);
                cell.DisableBorderSide(8);
                ptable.AddCell(cell);

                cell = new PdfPCell(new Phrase("      盤點薄", new iTextSharp.text.Font(bf, 18)));
                cell.VerticalAlignment = Element.ALIGN_LEFT;
                cell.Colspan = 3;
                cell.DisableBorderSide(1);
                cell.DisableBorderSide(2);
                cell.DisableBorderSide(4);
                cell.DisableBorderSide(8);
                ptable.AddCell(cell);

                cell = new PdfPCell(new Phrase("", new iTextSharp.text.Font(bf, 12)));
                cell.VerticalAlignment = Element.ALIGN_LEFT;//字體水平居左
                cell.Colspan = 3;
                cell.DisableBorderSide(1);
                cell.DisableBorderSide(2);
                cell.DisableBorderSide(4);
                // cell.DisableBorderSide(8);
                ptable.AddCell(cell);

                cell = new PdfPCell(new Phrase("", new iTextSharp.text.Font(bf, 12)));
                cell.VerticalAlignment = Element.ALIGN_LEFT;//字體水平居左
                cell.Colspan = 10;
                cell.DisableBorderSide(1);
                cell.DisableBorderSide(2);
                // cell.DisableBorderSide(4);
                //cell.DisableBorderSide(8);
                ptable.AddCell(cell);


                #endregion
                #region 表頭
                cell = new PdfPCell(new Phrase("編號", new iTextSharp.text.Font(bf, 12)));
                cell.VerticalAlignment = Element.ALIGN_LEFT;//字體水平居左
                cell.DisableBorderSide(8);
                ptable.AddCell(cell);

                cell = new PdfPCell(new Phrase("條碼", new iTextSharp.text.Font(bf, 12)));
                cell.VerticalAlignment = Element.ALIGN_LEFT;//字體水平居左
                cell.DisableBorderSide(8);
                ptable.AddCell(cell);



                cell = new PdfPCell(new Phrase("料位", new iTextSharp.text.Font(bf, 12)));
                cell.VerticalAlignment = Element.ALIGN_LEFT;//字體水平居左
                cell.DisableBorderSide(8);
                ptable.AddCell(cell);

                cell = new PdfPCell(new Phrase("現有庫存", new iTextSharp.text.Font(bf, 12)));
                cell.VerticalAlignment = Element.ALIGN_LEFT;//字體水平居左
                cell.DisableBorderSide(8);
                ptable.AddCell(cell);

                cell = new PdfPCell(new Phrase("盤點數量", new iTextSharp.text.Font(bf, 12)));
                cell.VerticalAlignment = Element.ALIGN_LEFT;//字體水平居左
                cell.DisableBorderSide(8);
                ptable.AddCell(cell);
                cell = new PdfPCell(new Phrase("效期控制", new iTextSharp.text.Font(bf, 12)));
                cell.VerticalAlignment = Element.ALIGN_LEFT;//字體水平居左
                cell.DisableBorderSide(8);
                ptable.AddCell(cell);
                cell = new PdfPCell(new Phrase("品名", new iTextSharp.text.Font(bf, 12)));
                cell.VerticalAlignment = Element.ALIGN_LEFT;//字體水平居左
                cell.DisableBorderSide(8);
                ptable.AddCell(cell);

                cell = new PdfPCell(new Phrase("規格", new iTextSharp.text.Font(bf, 12)));
                cell.VerticalAlignment = Element.ALIGN_LEFT;//字體水平居左
                cell.DisableBorderSide(8);
                ptable.AddCell(cell);
                cell = new PdfPCell(new Phrase("細項編號", new iTextSharp.text.Font(bf, 12)));
                cell.VerticalAlignment = Element.ALIGN_LEFT;//字體水平居左
                cell.DisableBorderSide(8);
                ptable.AddCell(cell);
                cell = new PdfPCell(new Phrase("備註", new iTextSharp.text.Font(bf, 12)));
                cell.VerticalAlignment = Element.ALIGN_LEFT;//字體水平居左
                ptable.AddCell(cell);
                #endregion
                #endregion
                document = new Document(PageSize.A4.Rotate());
                if (!document.IsOpen())
                {
                    document.Open();
                }
                cell = new PdfPCell(new Phrase(" ", font));
                cell.Colspan = 4;
                cell.VerticalAlignment = Element.ALIGN_CENTER;//字體水平居左
                cell.DisableBorderSide(8);
                ptable.AddCell(cell);

                cell = new PdfPCell(new Phrase("此工作代號無數據!", font));
                cell.Colspan = 3;
                cell.DisableBorderSide(4);
                cell.VerticalAlignment = Element.ALIGN_CENTER;//字體水平居左
                ptable.AddCell(cell);
                cell = new PdfPCell(new Phrase(" ", font));
                cell.Colspan = 3;
                cell.VerticalAlignment = Element.ALIGN_CENTER;//字體水平居左
                //cell.DisableBorderSide(8);
                ptable.AddCell(cell);


                // document.Add(ptable);
                //document.Add(ptablefoot); 
                newFileName = newPDFName + "_part" + index++ + "." + "pdf";
                pdf.ExportDataTableToPDF(_dtBody, false, newFileName, arrColWidth, ptable, ptablefoot, "", "", 10, uint.Parse(_dtBody.Rows.Count.ToString()));/*第一7是列,第二個是行*/
                pdfList.Add(newFileName);

            }
            newFileName = newPDFName + "." + "pdf";
            pdf.MergePDF(pdfList, newFileName);

            Response.Clear();
            Response.Charset = "gb2312";
            Response.ContentEncoding = System.Text.Encoding.UTF8;
            Response.AddHeader("Content-Disposition", "attach-ment;filename=" + filename + ".pdf");
            Response.WriteFile(newFileName);
        }
Exemplo n.º 4
0
        /// <summary>
        /// 匯出總報表
        /// </summary>
        /// <returns></returns>
        public HttpResponseBase GetAllCountBook()
        {
            string json = string.Empty;
            CbjobMasterQuery cbmaster = new CbjobMasterQuery();
           
            try
            {
                #region 查詢條件

                if (!string.IsNullOrEmpty(Request.Params["rowIDs"]))
                {
                    cbmaster.row_id_IN = Request.Params["rowIDs"].TrimEnd(',');
                }
                if (!string.IsNullOrEmpty(Request.Params["startDate"]) && Request.Params["startDate"].Substring(0, 10) != "1970-01-01")
                    {
                        cbmaster.startDate = DateTime.Parse(Request.Params["startDate"]).ToString("yyyy-MM-dd HH:mm:ss");
                    }
                if (!string.IsNullOrEmpty(Request.Params["endDate"]) && Request.Params["endDate"].Substring(0, 10) != "1970-01-01")
                    {
                        cbmaster.endDate = DateTime.Parse(Request.Params["endDate"]).ToString("yyyy-MM-dd HH:mm:ss");
                    }
                    if (!string.IsNullOrEmpty(Request.Params["sta_id"]))
                    {
                        cbmaster.sta_id = Request.Params["sta_id"];
                    }


                    if (!string.IsNullOrEmpty(Request.Params["jobStart"]) || !string.IsNullOrEmpty(Request.Params["jobEnd"]))
                    {
                        cbmaster.cbjob_id = "PC";
                        if (!string.IsNullOrEmpty(Request.Params["jobStart"]))
                        {
                            switch (Request.Params["jobStart"].Trim().Length)
                            {
                                case 0:
                                //cbmaster.cbjob_id  += "00";
                                //break;
                                case 1:
                                    cbmaster.cbjob_id += "%" + Request.Params["jobStart"].Trim().ToUpper();
                                    break;
                                default:
                                    cbmaster.cbjob_id += Request.Params["jobStart"].Trim().ToUpper().Substring(0, 2);
                                    break;
                            }
                        }
                        else
                        {
                            cbmaster.cbjob_id += "%";
                        }
                        if (!string.IsNullOrEmpty(Request.Params["jobEnd"]))
                        {
                            switch (Request.Params["jobEnd"].Trim().Length)
                            {
                                case 0:
                                //cbmaster.cbjob_id  += "00";
                                //break;
                                case 1:
                                    cbmaster.cbjob_id += "%" + Request.Params["jobEnd"].Trim().ToUpper();
                                    break;
                                default:
                                    cbmaster.cbjob_id += Request.Params["jobEnd"].Trim().ToUpper().Substring(0, 2);
                                    break;
                            }
                        }
                        else
                        {
                            cbmaster.cbjob_id += "%";
                        }
                        cbmaster.cbjob_id += "%";
                    }
                

                #endregion
                cbmaster.IsPage = false;
                List<CbjobMasterQuery> cbmasterList = new List<CbjobMasterQuery>();
                _CbjobMasterMgr = new CbjobMasterMgr(mySqlConnectionString);
                int totalCount = 0;
                cbmasterList = _CbjobMasterMgr.GetjobMaster(cbmaster, out  totalCount);
                if (cbmasterList.Count > 0)
                {
                    #region 生成報表
                    DataTable dtCountBook = new DataTable();
                   
                    #region MyRegion


                    dtCountBook.Columns.Add("NO.", typeof(String));
                    dtCountBook.Columns.Add("工作代號", typeof(String));
                    dtCountBook.Columns.Add("料位區間", typeof(String));
                    dtCountBook.Columns.Add("領取人員", typeof(String));
                    dtCountBook.Columns.Add("出去", typeof(String));
                    dtCountBook.Columns.Add("回來", typeof(String));
                    dtCountBook.Columns.Add("初盤KEY IN", typeof(String));
                    dtCountBook.Columns.Add("複盤結束", typeof(String));
                    dtCountBook.Columns.Add("盤點差異報表", typeof(String));
                    dtCountBook.Columns.Add("執行蓋帳", typeof(String));
                    for (int i = 0; i < cbmasterList.Count; i++)
                    {
                        DataRow dr = dtCountBook.NewRow();
                        dr[0] = i+1;
                        dr[1] = cbmasterList[i].cbjob_id;
                        string t = cbmasterList[i].cbjob_id.Substring(6,1);
                         string v = cbmasterList[i].cbjob_id.Substring(2,2)+"~"+cbmasterList[i].cbjob_id.Substring(4,2);
                         if (t == "S")
                         {
                             dr[2] = v + "(單)";
                         }
                         if (t == "M")
                         {
                             dr[2] = v + "(雙)";
                         }
                         if (t == "Z")
                         {
                             dr[2] = v;
                         }
                        dr[3] = " ";
                        dr[4] = " ";
                        dr[5] = " ";
                        dr[6] = " ";
                        dr[7] = " ";
                        dr[8] = " ";
                        dr[9] = " ";
                        
                        dtCountBook.Rows.Add(dr);
                    }
                    for (int i = 0; i < 3; i++)
                    {
                        DataRow dr = dtCountBook.NewRow();
                        dr[0] = "";
                        dr[1] = "";
                        dr[2] =" ";
                        dr[3] = " ";
                        dr[4] = " ";
                        dr[5] = " ";
                        dr[6] = " ";
                        dr[7] = " ";
                        dr[8] = " ";
                        dr[9] = " ";
                        if (i == 2)
                        {
                            dr[8] = "KEYIN人員:";
                            dr[9] = "_________";
                        }

                        dtCountBook.Rows.Add(dr);
                    }

                    //dtCountBook.Columns.RemoveAt(0);
                    
                    #endregion
                    #endregion
                    string fileName = "盤點進度控制總表" + DateTime.Now.ToString("-yyyyMMddHHmmss") + ".xls";
                    String str = "盤點進度控制總表" + DateTime.Now.ToString("-yyyyMMddHHmmss");
                    MemoryStream ms = ExcelHelperXhf.ExportDT(dtCountBook, str);
                    Response.AddHeader("Content-Disposition", "attachment; filename=" + fileName);
                    Response.BinaryWrite(ms.ToArray());
                }
                else
                {
                    Response.Clear();
                    this.Response.Write("該範圍內沒有數據<br/>");
                }
            }
            catch (Exception ex)
            {
                Log4NetCustom.LogMessage logMessage = new Log4NetCustom.LogMessage();
                logMessage.Content = string.Format("TargetSite:{0},Source:{1},Message:{2}", ex.TargetSite.Name, ex.Source, ex.Message);
                logMessage.MethodName = System.Reflection.MethodBase.GetCurrentMethod().Name;
                log.Error(logMessage);
            }
            return this.Response;
        }
Exemplo n.º 5
0
        /// <summary>
        /// 盤點工作列表頁
        /// </summary>
        /// <returns></returns>
        public HttpResponseBase GetGetjobMasterList()
        {
            string json = string.Empty;
            CbjobMasterQuery cbmaster = new CbjobMasterQuery();
            //if (!string.IsNullOrEmpty(Request.Params["start"]) && Request.Params["start"] != "NaN")
            //{
            cbmaster.Start = Convert.ToInt32(Request.Params["start"] ?? "0");//用於分頁的變量
            cbmaster.Limit = Convert.ToInt32(Request.Params["limit"] ?? "25");//用於分頁的變量
            //}
            //else
            //{
            //    cbmaster.Start = 0;
            //    cbmaster.Limit = 25;

            //}
            string content = string.Empty;
            
            #region 查詢條件
            
          
            if (!string.IsNullOrEmpty(Request.Params["startDate"]))
            {
                cbmaster.startDate = DateTime.Parse(Request.Params["startDate"]).ToString("yyyy-MM-dd HH:mm:ss");
            }
            if (!string.IsNullOrEmpty(Request.Params["endDate"]))
            {
                cbmaster.endDate = DateTime.Parse(Request.Params["endDate"]).ToString("yyyy-MM-dd HH:mm:ss");
            }
            if (!string.IsNullOrEmpty(Request.Params["sta_id"]))
            {
                cbmaster.sta_id = Request.Params["sta_id"];
            }
               

                if (!string.IsNullOrEmpty(Request.Params["jobStart"]) || !string.IsNullOrEmpty(Request.Params["jobEnd"]))
                { 
                    cbmaster.cbjob_id = "PC";
                    if (!string.IsNullOrEmpty(Request.Params["jobStart"]))
                    {
                        switch (Request.Params["jobStart"].Trim().Length)
                        {
                            case 0:
                            //cbmaster.cbjob_id  += "00";
                            //break;
                            case 1:
                                cbmaster.cbjob_id += "%" + Request.Params["jobStart"].Trim().ToUpper();
                                break;
                            default:
                                cbmaster.cbjob_id += Request.Params["jobStart"].Trim().ToUpper().Substring(0, 2);
                                break;
                        }
                    }
                    else
                    {
                        cbmaster.cbjob_id += "%";
                    }  
                    if (!string.IsNullOrEmpty(Request.Params["jobEnd"]))
                    {
                        switch (Request.Params["jobEnd"].Trim().Length)
                        {
                            case 0:
                            //cbmaster.cbjob_id  += "00";
                            //break;
                            case 1:
                                cbmaster.cbjob_id += "%" + Request.Params["jobEnd"].Trim().ToUpper();
                                break;
                            default:
                                cbmaster.cbjob_id += Request.Params["jobEnd"].Trim().ToUpper().Substring(0, 2);
                                break;
                        }
                    }
                    else
                    {
                        cbmaster.cbjob_id += "%";
                    }
                cbmaster.cbjob_id += "%";
                }
              
            #endregion
            
            try
            {
                List<CbjobMasterQuery> cbmasterList = new List<CbjobMasterQuery>();
                _CbjobMasterMgr = new CbjobMasterMgr(mySqlConnectionString);
                int totalCount = 0;
                cbmasterList = _CbjobMasterMgr.GetjobMaster(cbmaster, out  totalCount);
              
                IsoDateTimeConverter timeConverter = new IsoDateTimeConverter();
                //这里使用自定义日期格式,如果不使用的话,默认是ISO8601格式    ,totalCount:" + totalCount + " 
                timeConverter.DateTimeFormat = "yyyy-MM-dd HH:mm:ss";
                json = "{success:true,'msg':'user',totalCount:" + totalCount + ",data:" + JsonConvert.SerializeObject(cbmasterList, Formatting.Indented, timeConverter) + "}";//返回json數據
            }
            catch (Exception ex)
            {
                Log4NetCustom.LogMessage logMessage = new Log4NetCustom.LogMessage();
                logMessage.Content = string.Format("TargetSite:{0},Source:{1},Message:{2}", ex.TargetSite.Name, ex.Source, ex.Message);
                logMessage.MethodName = System.Reflection.MethodBase.GetCurrentMethod().Name;
                log.Error(logMessage);
                json = "{success:false,totalCount:0,data:[]}";
            }
            this.Response.Clear();
            this.Response.Write(json);
            this.Response.End();
            return this.Response;
        
        }