Esempio n. 1
0
        private void Form1_Load(object sender, EventArgs e)
        {
            SetMasterBindingNavigator(null);
            tabPage1.BackColor = this.BackColor;
            tabPage2.BackColor = this.BackColor;
            tabPage3.BackColor = this.BackColor;

            //取得此表單的LoaderFormInfo
            fFormInfo = XSC.ClientLoader.FormInfo(this);
            //透過LoginUserId取得sqlClientAccess
            sca = XSC.ClientAccess.UserAccess.sqlUserAccess(fFormInfo.LoginUserId);
            //fFormInfo.UserId;
            comboBox1.SelectedIndex = 0;

            object[] objParam = { "@userid", SqlDbType.NVarChar.ToString(), fFormInfo.LoginUserId };

            cmdstring = "Select EMPID From XSC_Menu_Userlist where XSC_UserID=@userid";
            DataTable dt = sca.GetDataTable("EEPDC", cmdstring, objParam, 0);

            if (dt.Rows.Count > 0)
            {
                Global.Globalparameter.UserName = dt.Rows[0]["EMPID"].ToString();
            }
            else
            {
                MessageBox.Show("找不到工號,無法使用外掛");
                Global.Globalparameter.UserName = "";
                button_Search.Enabled           = false;
            }

            toolStripStatusLabel1.Text = "XSC使用者:" + fFormInfo.UserId;
            toolStripStatusLabel2.Text = " WMS使用者工號:" + Global.Globalparameter.UserName;
        }
Esempio n. 2
0
 private void TestForm03_Load(object sender, EventArgs e)
 {
     //取得此表單的LoaderFormInfo
     fFormInfo = XSC.ClientLoader.FormInfo(this);
     //透過LoginUserId取得sqlClientAccess
     sca = XSC.ClientAccess.UserAccess.sqlUserAccess(fFormInfo.LoginUserId);
     comboBox1.SelectedIndex = 0;
 }
Esempio n. 3
0
        private void Form2_Load(object sender, EventArgs e)
        {
            fFormInfo = XSC.ClientLoader.FormInfo(this);

            sca1 = XSC.ClientAccess.UserAccess.sqlUserAccess(fFormInfo.LoginUserId);
            string sql = string.Format("select GROUPNAME from workitem_jack where wkclass='{0}'", v1);

            dt1 = sca1.GetDataTable(v2, sql);
            if (dt1.Rows.Count > 0)
            {
                v4 = dt1.Rows[0][0].ToString();
            }
            view1();
        }
        private void Form1_Load(object sender, EventArgs e)
        {
            //取得此表單的LoaderFormInfo
            fFormInfo = XSC.ClientLoader.FormInfo(this);
            //透過LoginUserId取得sqlClientAccess
            sca = XSC.ClientAccess.UserAccess.sqlUserAccess(fFormInfo.LoginUserId);

            SetButtonEnable("L");
            ResizeForm.ResizeForm.WSC_Resize(this, 1);
            label1.MaximumSize = new System.Drawing.Size(button1.Size.Width, 0);
            label2.MaximumSize = label1.MaximumSize;

            comboBox1.SelectedIndex = 0;
        }
Esempio n. 5
0
        private void Form1_Load(object sender, EventArgs e)
        {
            this.Text = "PO,RJ 產生PDF v" + FileVersionInfo.GetVersionInfo(Assembly.GetExecutingAssembly().Location).FileVersion.ToString();

            //取得此表單的LoaderFormInfo
            fFormInfo = XSC.ClientLoader.FormInfo(this);
            //透過LoginUserId取得sqlClientAccess
            sca             = XSC.ClientAccess.UserAccess.sqlUserAccess(fFormInfo.LoginUserId);
            label_Host.Text = fFormInfo.UserId;//fFormInfo.UserId;
            IPAddress[] iplist = Dns.GetHostEntry(Dns.GetHostName()).AddressList;
            bool        ismatch;

            foreach (IPAddress ip in iplist)
            {
                ismatch = Regex.IsMatch(ip.ToString(), ("^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$"));
                if (ismatch == true)
                {
                    label_IP.Text = ip.ToString() + "\n";
                    break;
                }
            }

            //設定預設值
            cmb_DockMode.SelectedIndex = 0;
            txb_POID.Text          = "P" + DateTime.Today.AddDays(-2).ToString("yyyyMMdd").Substring(2, 4);
            rdb_SelectPO.ForeColor = Color.Red;

            SetStatusString(0);
            label3.Text = "長度:" + txb_POID.Text.Length.ToString() + " (Max 13)";
            label5.Text = "長度:" + txb_SupID.Text.Length.ToString() + " (Max 4)";

            dtp_BDate.Value = DateTime.Today.AddDays(-3);
            dtp_EDate.Value = DateTime.Today.AddDays(3);

            //測試時使用
            //textBox_POID.Text = "5714010100080";
            //dateTimePicker1.Value = DateTime.Today.AddDays(-20);

            radioButton1_CheckedChanged(rdb_SelectPO, e);
        }
Esempio n. 6
0
        static public string CreatPdf_Prod(XSC.ClientAccess.sqlClientAccess sca, string PO, string siteno, string Host_string, string IP_string, string Mainfilepath)
        {
            string    returnstring = "";
            Document  doc          = new Document();
            string    filepath     = Mainfilepath;
            string    path;    //檔案路徑
            string    FileKey; //PO單號
            DataTable dt = new DataTable();

            //產生字型檔,圖檔,然後刪除
            if (File.Exists(Environment.CurrentDirectory + "\\WMSADJ\\logo.jpg") == false)
            {
                return("無logo.jpg,請嘗試重開程式");
            }
            if (File.Exists(Environment.CurrentDirectory + "\\WMSADJ\\IDAutomationHC39M_FREE.otf") == false)
            {
                return("無otf,請嘗試重開程式");
            }
            if (File.Exists(Environment.CurrentDirectory + "\\WMSADJ\\kaiu.ttf") == false)
            {
                return("無ttf,請嘗試重開程式");
            }

            #region 初使參數設定
            // 定義字型
            BaseFont bfChinese =
                BaseFont.CreateFont(Environment.CurrentDirectory + "\\WMSADJ\\kaiu.ttf", BaseFont.IDENTITY_H, BaseFont.NOT_EMBEDDED);//中文字型標楷體
            BaseFont bfCode =
                //BaseFont.CreateFont(@"C:\WINDOWS\Fonts\3of9.ttf", BaseFont.IDENTITY_H, BaseFont.NOT_EMBEDDED);
                BaseFont.CreateFont(Environment.CurrentDirectory + "\\WMSADJ\\IDAutomationHC39M_FREE.otf", BaseFont.IDENTITY_H, BaseFont.NOT_EMBEDDED);

            //標題
            Paragraph h = new Paragraph();
            h.Alignment = Element.ALIGN_CENTER;
            h.Font      = new Font(bfChinese, 32, Font.BOLD + Font.NORMAL, BaseColor.BLACK);
            h.SetLeading(0.0f, 0.9f);

            // 內容
            Paragraph h_title = new Paragraph();
            h_title.Alignment = Element.ALIGN_CENTER;
            h_title.Font      = new Font(bfChinese, 20, Font.BOLD + Font.NORMAL, BaseColor.BLACK);
            h_title.SetLeading(2.0f, 0.9f);

            // 條碼
            Paragraph h_Code = new Paragraph();
            h_Code.Alignment = Element.ALIGN_CENTER;
            h_Code.Font      = new Font(bfCode, 32);//, Font.NORMAL,, BaseColor.BLACK);
            h_Code.SetLeading(0.0f, 0.9f);


            // 空白行
            Paragraph h_newline = new Paragraph();
            h_newline.Alignment = Element.ALIGN_CENTER;
            h_newline.Font      = new Font(bfChinese, 10, Font.BOLD + Font.NORMAL, BaseColor.BLUE);
            h_newline.SetLeading(0.0f, 0.9f);
            h_newline.Add(" ");

            // 空白行(大)
            Paragraph h_newline_L = new Paragraph();
            h_newline_L.Alignment = Element.ALIGN_CENTER;
            h_newline_L.Font      = new Font(bfChinese, 72, Font.BOLD + Font.NORMAL, BaseColor.BLUE);
            h_newline_L.SetLeading(0.0f, 0.9f);
            h_newline_L.Add(" ");
            #endregion

            try
            {
                #region  找PO單
                string sqlcommand =
                    @"
                select 
                SITE_NO_Descr=SITE_NO_Descr+'['+DOCK_MODE_Descr+']',
                PO_NO,
                VENDOR_NO=VENDOR_NO+VENDOR_Name,
                ARRIVE_DATE,
                ARRIVE_START_TIME=ARRIVE_START_TIME+'-'+ARRIVE_END_TIME,
                RECEIVE_PLACE_ADDR,
                remark,
                remark2,
                SITE_NO,
                ITEM_SEQ_NO,
                ITEM_NO=ITEM_NO+CASE WHEN WARM_LAYER!='' THEN '('+WARM_LAYER+')' ELSE '' END,
                NAME,
                QTY,
                IP_QTY,
                WARM_LAYER,

                EA_Barcode,
                INNER_QTY,
                MANUFACTURING_DAYS=CASE WHEN MANUFACTURING_DAYS=MATURITIES_DAYS THEN '無保存期限' ELSE Replace(MATURITIES_DAYS,'/','')+'後生產' END,
                MATURITIES_DAYS=CASE WHEN MANUFACTURING_DAYS=MATURITIES_DAYS THEN '' ELSE Replace(MATURITIES_DAYS,'/','')+'後到期' END,
                IP_Barcode,

                CS_Barcode,
                Packing_memo,
                Carton_QTY=convert(varchar,Carton_QTY)+CS_UNIT,
                VENDOR_ITEM_NO,
                TI=convert(varchar,TI)+'底/'+convert(varchar,HI)+'高',
                TotalCase
                from v_T_PO 
                where PO_NO=@po_no 
                and site_no=@site_no";
                object[] scaParam = { "@po_no",   "NVarChar", PO,
                                      "@site_no", "NVarChar", siteno };
                dt           = sca.GetDataTable("EDI_DC", sqlcommand, scaParam, 0);
                dt.TableName = "v_T_PO";
                if (dt.Rows.Count == 0)
                {
                    returnstring += "找不到資料,請確認PO單號存在";
                    return(returnstring);
                }
                #endregion

                #region 記錄log
                sqlcommand = "insert into RunLog (JobID,JobType,JobDate,JobCmd,Crt_date) "
                             + " values('',"                       //JobID
                             + "'手動產生PDF"                          //JobType
                             + "',CONVERT(CHAR(10),GETDATE(),112)" //JobDate
                             + ",'PDF_PO_Kota.exe " + PO
                             + "," + System.Security.Principal.WindowsIdentity.GetCurrent().Name
                             + "," + Host_string
                             + "," + IP_string  //JobCmd
                             + "',GETDATE()) "; //Crt_date
                sca.Update("LGDC", sqlcommand, scaParam, 0);
                #endregion

                DataRow dr = dt.Rows[0];

                FileKey = dr["PO_NO"].ToString();
                string FileKey_ = "";

                PdfPCell  pCell_tmp;
                PdfPTable p;
                int       Font_Size = 10;

                #region Logo

                //  公司Logo
                string Img_url            = Environment.CurrentDirectory + "\\WMSADJ\\logo.jpg";
                iTextSharp.text.Image jpg = iTextSharp.text.Image.GetInstance(new Uri(Img_url));

                jpg.ScalePercent(60);

                PdfPCell jpgcell = new PdfPCell(jpg);
                jpgcell.Border            = 0;
                jpgcell.Colspan           = 2;
                jpgcell.Column.Alignment  = Element.ALIGN_CENTER;
                jpgcell.VerticalAlignment = Element.ALIGN_CENTER;
                #endregion

                int INNER_QTY         = 0;
                int QTY               = 0;
                int QTY_div_INNER_QTY = 0;

                // 分頁
                int row_page         = 13; //每頁幾筆
                int row_Count_PDFNow = 0;  //pdf第幾頁
                int row_Count_Now    = 0;  //第幾筆
                int Page             = 0;  //總頁碼
                int pageEnd          = 0;  //結束頁

                p = new PdfPTable(3);
                string strTotalCase = "";
                foreach (DataRow drt in dt.Rows)
                {
                    FileKey = drt["PO_NO"].ToString();

                    #region 允收日期    2014/01/07
                    string RecDateS = "", RecDateE = "";
                    if (drt["MANUFACTURING_DAYS"].ToString() == drt["MATURITIES_DAYS"].ToString())
                    {
                        RecDateS = "無保存期限";
                        RecDateE = "";
                    }
                    else
                    {
                        RecDateS = string.Format("{0:yyyy/MM/dd}", drt["MANUFACTURING_DAYS"]).Replace("/", "") + "後生產";
                        RecDateE = string.Format("{0:yyyy/MM/dd}", drt["MATURITIES_DAYS"]).Replace("/", "") + "後到期";
                    }
                    #endregion

                    #region 溫層 2014/01/07
                    string WarmLayer = "";
                    if (drt["WARM_LAYER"].ToString() != "")
                    {
                        WarmLayer = "(" + drt["WARM_LAYER"].ToString() + ")";
                    }
                    #endregion

                    #region 單據不同則產生單據
                    if (FileKey_ != FileKey)
                    {
                        if (FileKey_ != "")
                        {
                            //尾頁
                            p = PageEnd(bfChinese, doc, h_newline, p, Font_Size);
                            //簽收
                            PageEndSign(bfChinese, row_Count_Now, row_page, pageEnd, Font_Size, p, Page, doc);
                        }


                        //頁碼重新計算
                        row_Count_PDFNow = 0;
                        row_Count_Now    = 0;
                        Page             = 0;
                        pageEnd          = 0;

                        DataRow[] PageRows;
                        string    expression;
                        expression = "PO_NO = '" + FileKey + "'";
                        PageRows   = dt.Select(expression);
                        int row_Count = PageRows.Length;  //單號-總筆數

                        if (row_Count % row_page > 0)
                        {
                            Page = row_Count / row_page + 1;
                        }
                        else
                        {
                            Page = row_Count / row_page;
                        }

                        FileKey_ = FileKey;

                        doc = new Document(PageSize.A4, 20, 15, 15, 15);

                        path = filepath + "\\" + FileKey.Trim() + "_" + drt["SITE_NO"].ToString().Trim() + ".pdf";
                        if (path != "")
                        {
                            PdfWriter writer = PdfWriter.GetInstance(doc, new FileStream(path, FileMode.Create));
                            writer.PageEvent = new PDFFooter();

                            returnstring += "PDF產生完成  " + path;
                        }
                        else
                        {
                            returnstring += FileKey.Trim() + "  路徑有誤,請重新產生";
                            return(returnstring);
                        }
                        doc.Open();
                        row_Count_Now = 0;
                    }
                    #endregion

                    row_Count_Now++;
                    row_Count_PDFNow++;

                    #region 換頁時重印單頭
                    if ((row_Count_Now % row_page) == 1)
                    {
                        if (row_Count_Now > row_page)
                        {
                            doc.Add(p);
                            doc.Add(h_newline);
                            p = new PdfPTable(1);
                            p.WidthPercentage = 100;
                            pCell_tmp         = new PdfPCell();


                            pCell_tmp = setTable_Cell(bfChinese, string.Format(@"{0} / {1} ", row_Count_PDFNow / row_page, Page)//row_Count / row_page
                                                      , 0, Font_Size, Element.ALIGN_RIGHT, 3, 1);
                            p.AddCell(pCell_tmp);
                            doc.Add(p);

                            doc.NewPage();
                        }

                        #region 表頭
                        p = new PdfPTable(5);
                        p.WidthPercentage = 110;

                        //送貨通知單
                        pCell_tmp            = setTable_Cell(bfChinese, "送貨通知單", 0, Font_Size + 4, Element.ALIGN_CENTER, 1, 1);
                        pCell_tmp.Colspan    = 5;
                        pCell_tmp.PaddingTop = 7f;
                        p.AddCell(pCell_tmp);

                        //Logo
                        p.AddCell(jpgcell);

                        //ex:觀音物流中心[越庫馬頭]
                        p.AddCell(setTable_Cell(bfChinese, string.Format("{0}", drt["SITE_NO_Descr"]), 0, Font_Size, Element.ALIGN_CENTER, 1, 1, 7f));//SITE_NO,SITE_NO_Descr,DOCK_MODE_Descr

                        // 條碼
                        h_Code.Clear();
                        h_Code.Alignment = Element.ALIGN_RIGHT;
                        h_Code.Font      = new Font(bfCode, 12);//, Font.NORMAL,, BaseColor.BLACK);
                        h_Code.Add(string.Format("{0}", "*" + drt["PO_NO"] + "*"));
                        pCell_tmp                   = new PdfPCell(h_Code);
                        pCell_tmp.Border            = 0;
                        pCell_tmp.Colspan           = 2;
                        pCell_tmp.Column.Alignment  = Element.ALIGN_CENTER;
                        pCell_tmp.VerticalAlignment = Element.ALIGN_CENTER;
                        p.AddCell(pCell_tmp);

                        //  p.AddCell(setTable_Cell(string.Format("單號:{0}", drt["PO_NO"]), 0, Font_Size, Element.ALIGN_CENTER, 2, 1));
                        p.AddCell(setTable_Cell(bfChinese, string.Format("    廠商:{0}", drt["VENDOR_NO"]), 0, Font_Size, Element.ALIGN_LEFT, 2, 1, 7f));
                        p.AddCell(setTable_Cell(bfChinese, string.Format("  到貨日期:{0}", drt["ARRIVE_DATE"].ToString().Substring(0, 10)), 0, Font_Size, Element.ALIGN_LEFT, 1, 1, 7f));
                        p.AddCell(setTable_Cell(bfChinese, string.Format("        單號:{0}", drt["PO_NO"]), 0, Font_Size, Element.ALIGN_LEFT, 2, 1, 7f));


                        p.AddCell(setTable_Cell(bfChinese, string.Format("  列印時間:{0}", DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss")), 0, Font_Size, Element.ALIGN_LEFT, 2, 1, 7f));
                        p.AddCell(setTable_Cell(bfChinese, string.Format("預計進廠起迄:{0}", drt["ARRIVE_START_TIME"]), 0, Font_Size, Element.ALIGN_LEFT, 1, 1, 7f));
                        p.AddCell(setTable_Cell(bfChinese, "      客服電話:(886)0800335888", 0, Font_Size, Element.ALIGN_LEFT, 2, 1, 7f));

                        p.AddCell(setTable_Cell(bfChinese, string.Format("  到貨地址:{0}", drt["RECEIVE_PLACE_ADDR"].ToString().Trim()), 0, Font_Size, Element.ALIGN_LEFT, 2, 1, 7f));
                        p.AddCell(setTable_Cell(bfChinese, string.Format("{0}", drt["remark"]), 0, Font_Size, Element.ALIGN_LEFT, 3, 1, 7f));

                        p.AddCell(setTable_Cell(bfChinese, string.Format("{0}", drt["remark2"]), 0, Font_Size, Element.ALIGN_CENTER, 5, 1, 7f));


                        //// 空行
                        p.AddCell(pCell_tmp);

                        doc.Add(p);

                        #endregion

                        #region 表身的頭
                        float[] widths = { 0.5f, 1.5f, 2f, 1.4f, 0.6f, 1.5f, 1.2f };
                        p = new PdfPTable(widths);//7
                        p.WidthPercentage = 100;

                        p.AddCell(setTable_Cell_Bottom(bfChinese, " ", 0, Font_Size - 1, Element.ALIGN_CENTER, 1, 3));
                        p.AddCell(setTable_Cell_Bottom(bfChinese, "貨號/條碼/外箱條碼", 0, Font_Size - 1, Element.ALIGN_CENTER, 1, 3));
                        p.AddCell(setTable_Cell_Bottom(bfChinese, "貨品名稱/規格/包裝組別", 0, Font_Size - 1, Element.ALIGN_CENTER, 1, 3));
                        p.AddCell(setTable_Cell_Bottom(bfChinese, "訂購量/入數/箱數", 0, Font_Size - 1, Element.ALIGN_CENTER, 1, 3));
                        p.AddCell(setTable_Cell_Bottom(bfChinese, "實收量", 0, Font_Size - 1, Element.ALIGN_CENTER, 1, 3));
                        p.AddCell(setTable_Cell_Bottom(bfChinese, "允收日期/廠商貨號", 0, Font_Size - 1, Element.ALIGN_CENTER, 1, 3));
                        p.AddCell(setTable_Cell_Bottom(bfChinese, "小包裝/棧板堆疊", 0, Font_Size - 1, Element.ALIGN_CENTER, 1, 3));
                        #endregion
                    }
                    #endregion

                    INNER_QTY = Convert.ToInt32(drt["INNER_QTY"].ToString());
                    QTY       = Convert.ToInt32(drt["QTY"].ToString());

                    #region 表身明細
                    //序號 Table
                    //
                    p.AddCell(setTable_Cell_Bottom(bfChinese, string.Format("{0}", drt["ITEM_SEQ_NO"]), 0, Font_Size, Element.ALIGN_CENTER, 1, 3));//ITEM_SEQ_NO
                    //貨號
                    p.AddCell(setTable_Cell(bfChinese, string.Format("{0}", drt["ITEM_NO"]) + WarmLayer, 0, Font_Size, Element.ALIGN_LEFT, 1, 1));
                    //貨品名稱
                    p.AddCell(setTable_Cell(bfChinese, string.Format("{0}", drt["NAME"]), 0, Font_Size - 1, Element.ALIGN_MIDDLE, 1, 2));
                    //訂購量
                    p.AddCell(setTable_Cell(bfChinese, string.Format("{0}", QTY), 0, Font_Size, Element.ALIGN_RIGHT, 1, 1));
                    //實收量
                    p.AddCell(setTable_Cell_Bottom(bfChinese, string.Format("{0}", ""), 0, Font_Size, Element.ALIGN_CENTER, 1, 3));
                    //允收日期1
                    p.AddCell(setTable_Cell(bfChinese, RecDateS, 0, Font_Size - 1, Element.ALIGN_CENTER, 1, 1));
                    //小包裝
                    //0 和 null 都要顯示 ""
                    Object IP_qty;
                    switch (drt["IP_QTY"].ToString())
                    {
                    case "0": IP_qty = ""; break;

                    default: IP_qty = drt["IP_QTY"]; break;
                    }
                    p.AddCell(setTable_Cell(bfChinese, string.Format("{0}", IP_qty), 0, Font_Size, Element.ALIGN_RIGHT, 1, 1));

                    //資料列 第2排----------------------------------------------------------------------------------------------------------
                    //條碼
                    p.AddCell(setTable_Cell(bfChinese, string.Format("{0}", drt["EA_BARCODE"]), 0, Font_Size, Element.ALIGN_LEFT, 1, 1));
                    //入數
                    p.AddCell(setTable_Cell(bfChinese, string.Format("{0}", INNER_QTY), 0, Font_Size, Element.ALIGN_RIGHT, 1, 1));
                    //允收日期2
                    p.AddCell(setTable_Cell(bfChinese, RecDateE, 0, Font_Size - 1, Element.ALIGN_CENTER, 1, 1));
                    //棧板堆疊-底
                    p.AddCell(setTable_Cell(bfChinese, string.Format("{0}", drt["IP_Barcode"]), 0, Font_Size, Element.ALIGN_RIGHT, 1, 1));

                    //資料列 第3排-------------------------------------------------------------------------------------------------------------------------------------
                    //外箱條碼
                    p.AddCell(setTable_Cell_Bottom(bfChinese, string.Format("{0}", drt["CS_BARCODE"]), 0, Font_Size, Element.ALIGN_LEFT, 1, 1));
                    //贈品
                    p.AddCell(setTable_Cell_Bottom(bfChinese, string.Format("{0}", drt["Packing_memo"]), 0, Font_Size, Element.ALIGN_CENTER, 1, 1));
                    if (INNER_QTY != 0)
                    {
                        QTY_div_INNER_QTY = QTY / INNER_QTY;
                    }
                    else
                    {
                        QTY_div_INNER_QTY = 0;
                    }
                    //箱數
                    p.AddCell(setTable_Cell_Bottom(bfChinese, string.Format("{0}", drt["Carton_QTY"]), 0, Font_Size, Element.ALIGN_RIGHT, 1, 1));
                    //廠商貨號
                    p.AddCell(setTable_Cell_Bottom(bfChinese, string.Format("{0}", drt["VENDOR_ITEM_NO"]), 0, Font_Size, Element.ALIGN_CENTER, 1, 1));
                    //棧板堆疊-高
                    p.AddCell(setTable_Cell_Bottom(bfChinese, string.Format("{0}", drt["TI"]), 0, Font_Size, Element.ALIGN_RIGHT, 1, 1));

                    strTotalCase = drt["TotalCase"].ToString();

                    #endregion
                }
                doc.Add(p);
                doc.Add(h_newline);
                //總箱量
                setTable_Boxes(bfChinese, p, Font_Size, strTotalCase, doc);


                //尾頁
                p = PageEnd(bfChinese, doc, h_newline, p, Font_Size);
                //簽收
                PageEndSign(bfChinese, row_Count_Now, row_page, pageEnd, Font_Size, p, Page, doc);
            }
            catch (Exception err)
            {
                returnstring += "發生錯誤\n" + err.Message + "\n";
                //throw new Exception(err.Message);
            }
            finally
            {
                doc.Close();
            }

            return(returnstring);
        }
Esempio n. 7
0
        static public string CreatPdf_Prod(XSC.ClientAccess.sqlClientAccess sca, string RJ, string siteno, string Host_string, string IP_string, string Mainfilepath)
        {
            string    returnstring = "";
            Document  doc          = new Document();
            string    filepath     = Mainfilepath;
            string    path;    //檔案路徑
            string    FileKey; //PO單號
            DataTable dt = new DataTable();

            //產生字型檔,圖檔,然後刪除
            if (File.Exists(Environment.CurrentDirectory + "\\WMSADJ\\logo.jpg") == false)
            {
                return("無logo.jpg,請嘗試重開程式");
            }
            if (File.Exists(Environment.CurrentDirectory + "\\WMSADJ\\IDAutomationHC39M_FREE.otf") == false)
            {
                return("無otf,請嘗試重開程式");
            }
            if (File.Exists(Environment.CurrentDirectory + "\\WMSADJ\\kaiu.ttf") == false)
            {
                return("無ttf,請嘗試重開程式");
            }

            #region 初使參數設定
            // 定義字型
            BaseFont bfChinese =
                BaseFont.CreateFont(Environment.CurrentDirectory + "\\WMSADJ\\kaiu.ttf", BaseFont.IDENTITY_H, BaseFont.NOT_EMBEDDED);//中文字型標楷體
            BaseFont bfCode =
                //BaseFont.CreateFont(@"C:\WINDOWS\Fonts\3of9.ttf", BaseFont.IDENTITY_H, BaseFont.NOT_EMBEDDED);
                BaseFont.CreateFont(Environment.CurrentDirectory + "\\WMSADJ\\IDAutomationHC39M_FREE.otf", BaseFont.IDENTITY_H, BaseFont.NOT_EMBEDDED);

            //標題
            Paragraph h = new Paragraph();
            h.Alignment = Element.ALIGN_CENTER;
            h.Font      = new Font(bfChinese, 32, Font.BOLD + Font.NORMAL, BaseColor.BLACK);
            h.SetLeading(0.0f, 0.9f);

            // 內容
            Paragraph h_title = new Paragraph();
            h_title.Alignment = Element.ALIGN_CENTER;
            h_title.Font      = new Font(bfChinese, 20, Font.BOLD + Font.NORMAL, BaseColor.BLACK);
            h_title.SetLeading(2.0f, 0.9f);

            // 條碼
            Paragraph h_Code = new Paragraph();
            h_Code.Alignment = Element.ALIGN_CENTER;
            h_Code.Font      = new Font(bfCode, 32);//, Font.NORMAL,, BaseColor.BLACK);
            h_Code.SetLeading(0.0f, 0.9f);


            // 空白行
            Paragraph h_newline = new Paragraph();
            h_newline.Alignment = Element.ALIGN_CENTER;
            h_newline.Font      = new Font(bfChinese, 10, Font.BOLD + Font.NORMAL, BaseColor.BLUE);
            h_newline.SetLeading(0.0f, 0.9f);
            h_newline.Add(" ");

            // 空白行(大)
            Paragraph h_newline_L = new Paragraph();
            h_newline_L.Alignment = Element.ALIGN_CENTER;
            h_newline_L.Font      = new Font(bfChinese, 72, Font.BOLD + Font.NORMAL, BaseColor.BLUE);
            h_newline_L.SetLeading(0.0f, 0.9f);
            h_newline_L.Add(" ");

            #endregion

            try
            {
                #region  找RJ單
                string   sqlcommand = "select * from V_EDI_BACK_R02_T where RJ_NO=@po_no and site_no=@site_no";
                object[] scaParam   = { "@po_no", "NVarChar", RJ,
                                        "@site_no", "NVarChar", siteno };
                dt = sca.GetDataTable("EDI_DC", sqlcommand, scaParam, 0);
                if (dt.Rows.Count == 0)
                {
                    returnstring += "找不到資料,請確認RJ單號存在";
                    return(returnstring);
                }
                #endregion

                #region 記錄log
                sqlcommand = "insert into LGDC.dbo.RunLog (JobID,JobType,JobDate,JobCmd,Crt_date) "
                             + " values('',"                       //JobID
                             + "'手動產生PDF"                          //JobType
                             + "',CONVERT(CHAR(10),GETDATE(),112)" //JobDate
                             + ",'PDF_PO_Kota.exe " + RJ
                             + "," + System.Security.Principal.WindowsIdentity.GetCurrent().Name
                             + "," + Host_string
                             + "," + IP_string  //JobCmd
                             + "',GETDATE()) "; //Crt_date
                sca.Update("LGDC", sqlcommand, scaParam, 0);
                #endregion

                DataRow dr = dt.Rows[0];


                FileKey = dr["RJ_NO"].ToString();
                string FileKey_ = "";

                PdfPCell  pCell_tmp;
                PdfPTable p;
                int       Border_type   = Rectangle.BOTTOM_BORDER;
                int       Border_type_H = Rectangle.NO_BORDER;
                int       Font_Size     = 10;
                int       Font_Size_8   = 9;
                int       Font_Size_7   = 7;

                #region 預計實作功能 圖片及條碼

                // string Img_url = @"C:\Fpxmart\logo.jpg";//  公司Logo

                string Img_url            = Environment.CurrentDirectory + "\\WMSADJ\\logo.jpg";
                iTextSharp.text.Image jpg = iTextSharp.text.Image.GetInstance(new Uri(Img_url));

                jpg.ScalePercent(60);

                PdfPCell jpgcell = new PdfPCell(jpg);
                jpgcell.Border            = 0;
                jpgcell.Colspan           = 1;
                jpgcell.Column.Alignment  = Element.ALIGN_CENTER;
                jpgcell.VerticalAlignment = Element.ALIGN_CENTER;
                #endregion

                int INNER_QTY = 0;
                int QTY       = 0;

                // 分頁
                int row_page         = 16; //每頁幾筆
                int row_Count_PDFNow = 0;  //pdf第幾頁
                int row_Count_Now    = 0;  //第幾筆
                int Page             = 0;  //總頁碼
                int pageEnd          = 0;  //結束頁


                p = new PdfPTable(3);
                foreach (DataRow drt in dt.Rows)
                {
                    FileKey = drt["RJ_NO"].ToString();

                    #region 單據不同則產生單據
                    if (FileKey_ != FileKey)
                    {
                        if (FileKey_ != "")
                        {
                            doc.Add(p);
                            doc.Add(h_newline);

                            //尾頁
                            p = PageEnd(bfChinese, doc, h_newline, p, Font_Size);
                            //簽收
                            PageEndSign(bfChinese, row_Count_Now, row_page, pageEnd, Font_Size, p, Page, doc);
                        }
                        //頁碼重新計算
                        row_Count_PDFNow = 0;
                        row_Count_Now    = 0;
                        Page             = 0;
                        pageEnd          = 0;

                        DataRow[] PageRows;
                        string    expression;
                        expression = "RJ_NO = '" + FileKey + "'";
                        PageRows   = dt.Select(expression);
                        int row_Count = PageRows.Length;  //單號-總筆數

                        if (row_Count % row_page > 0)
                        {
                            Page = row_Count / row_page + 1;
                        }
                        else
                        {
                            Page = row_Count / row_page;
                        }
                        FileKey_ = FileKey;
                        if (FileKey_ != "")
                        {
                            doc.Close();
                        }

                        doc = new Document(PageSize.A4, 20, 15, 15, 15);

                        path = filepath + "\\RJ" + FileKey.Trim() + "_" + drt["SITE_NO"].ToString().Trim() + ".pdf";
                        if (path != "")
                        {
                            PdfWriter.GetInstance(doc, new FileStream(path, FileMode.Create));
                            returnstring += "PDF產生完成  " + path;
                        }
                        else
                        {
                            returnstring += FileKey.Trim() + "  路徑有誤,請重新產生";
                            return(returnstring);
                        }
                        doc.Open();
                        row_Count_Now = 0;
                    }
                    #endregion

                    row_Count_Now++;
                    row_Count_PDFNow++;

                    if ((row_Count_Now % row_page) == 1)
                    {
                        if (row_Count_Now > row_page)
                        {
                            doc.Add(p);
                            doc.Add(h_newline);
                            p = new PdfPTable(1);
                            p.WidthPercentage = 100;
                            pCell_tmp         = new PdfPCell();
                            pCell_tmp         = setTable_Cell(bfChinese, string.Format(@"{0} / {1} ", row_Count_PDFNow / row_page, Page)
                                                              , 0, Font_Size, Element.ALIGN_RIGHT, 1, 1);
                            p.AddCell(pCell_tmp);
                            doc.Add(p);
                            doc.NewPage();
                        }

                        #region 表頭
                        p = new PdfPTable(3);
                        p.WidthPercentage = 110;

                        pCell_tmp            = setTable_Cell(bfChinese, "退貨通知單", 0, Font_Size + 4, Element.ALIGN_CENTER, 1, 1);
                        pCell_tmp.Colspan    = 3;
                        pCell_tmp.PaddingTop = 7f;
                        p.AddCell(pCell_tmp);

                        //圖案
                        p.AddCell(jpgcell);

                        p.AddCell(setTable_Cell(bfChinese, string.Format("{0}越庫中心", drt["SITE_NO_DESCR"].ToString()), 0, Font_Size, Element.ALIGN_CENTER, 1, 1));

                        //條碼
                        h_Code.Clear();
                        h_Code.Alignment = Element.ALIGN_RIGHT;
                        h_Code.Font      = new Font(bfCode, 11);//, Font.NORMAL,, BaseColor.BLACK);
                        h_Code.Add(string.Format("{0}", "*" + drt["RJ_NO"].ToString().Trim() + "*"));
                        pCell_tmp = new PdfPCell(h_Code);

                        pCell_tmp.Column.Alignment  = Element.ALIGN_CENTER;
                        pCell_tmp.VerticalAlignment = Element.ALIGN_CENTER;
                        pCell_tmp.Colspan           = 1;
                        pCell_tmp.Border            = 0;
                        p.AddCell(pCell_tmp);

                        string strSD = DateTime.Parse(drt["ARRIVE_DATE"].ToString().Substring(0, 9)).ToString("yyyy/MM/dd");
                        string strED = DateTime.Parse(drt["CLOSE_DATE"].ToString().Substring(0, 9)).ToString("yyyy/MM/dd");

                        p.AddCell(setTable_Cell(bfChinese, string.Format("    廠商:{0}", drt["VENDOR_NO"].ToString() + drt["VENDOR_NAME"].ToString()), Border_type_H, Font_Size, Element.ALIGN_LEFT, 1, 1, 7f));
                        p.AddCell(setTable_Cell(bfChinese, string.Format("  通知日期:{0}", strSD), Border_type_H, Font_Size, Element.ALIGN_LEFT, 1, 1, 7f));
                        p.AddCell(setTable_Cell(bfChinese, string.Format("    單號:{0}", drt["RJ_NO"]), Border_type_H, Font_Size, Element.ALIGN_LEFT, 1, 1, 7f));

                        p.AddCell(setTable_Cell(bfChinese, string.Format("  列印時間:{0}", DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss")), Border_type_H, Font_Size_8, Element.ALIGN_LEFT, 1, 1, 7f));
                        p.AddCell(setTable_Cell(bfChinese, string.Format("預計退貨日起迄:{0}", strSD + "~" + strED + "(" + drt["ARRIVE_START_TIME"].ToString().Trim() + "-" + drt["ARRIVE_END_TIME"].ToString().Trim() + ")"), Border_type_H, Font_Size_7, Element.ALIGN_LEFT, 1, 1, 7f));
                        p.AddCell(setTable_Cell(bfChinese, "    客服電話:(886)0800335888", Border_type_H, Font_Size_8, Element.ALIGN_LEFT, 1, 1, 7f));

                        doc.Add(p);
                        doc.Add(h_newline);
                        #endregion

                        #region 表身的頭
                        p = new PdfPTable(7);
                        p.WidthPercentage = 100;

                        // int[] widths = {5, 20, 25, 10, 10,10,20 };
                        float[] widths = { 0.5f, 1.5f, 2.5f, 1.5f, 0.8f, 1.2f, 1.2f };
                        p.SetWidths(widths);

                        p.AddCell(setTable_Cell_Bottom(bfChinese, " ", Border_type, Font_Size, Element.ALIGN_CENTER, 1, 1));
                        p.AddCell(setTable_Cell_Bottom(bfChinese, "貨號/條碼", Border_type, Font_Size, Element.ALIGN_CENTER, 1, 1));
                        p.AddCell(setTable_Cell_Bottom(bfChinese, "貨品名稱/規格", Border_type, Font_Size, Element.ALIGN_CENTER, 1, 1));
                        p.AddCell(setTable_Cell_Bottom(bfChinese, "退貨量(pcs)", Border_type, Font_Size, Element.ALIGN_RIGHT, 1, 1));
                        p.AddCell(setTable_Cell_Bottom(bfChinese, "實退量", Border_type, Font_Size, Element.ALIGN_RIGHT, 1, 1));
                        p.AddCell(setTable_Cell_Bottom(bfChinese, "單位", Border_type, Font_Size, Element.ALIGN_CENTER, 1, 1));
                        p.AddCell(setTable_Cell_Bottom(bfChinese, "備註", Border_type, Font_Size, Element.ALIGN_CENTER, 1, 1));
                        #endregion
                    }
                    INNER_QTY = Convert.ToInt32(drt["INNER_QTY"].ToString());
                    QTY       = Convert.ToInt32(drt["QTY"].ToString());

                    #region 表身明細
                    //序號 Table
                    p.AddCell(setTable_Cell(bfChinese, "", Border_type_H, Font_Size, Element.ALIGN_CENTER, 1, 1));                                              //序號
                    p.AddCell(setTable_Cell(bfChinese, string.Format("{0}", drt["ITEM_NO"]), Border_type_H, Font_Size, Element.ALIGN_LEFT, 1, 1));              //貨號
                    p.AddCell(setTable_Cell_Bottom(bfChinese, string.Format("{0}", drt["NAME"]), Border_type_H, Font_Size, Element.ALIGN_LEFT, 1, 2));          //貨品名稱/規格
                    //p.AddCell(setTable_Cell_Bottom(string.Format("{0}", drt["RJT_QTY"]), Border_type_H, Font_Size, Element.ALIGN_RIGHT, 1, 2));//退貨量
                    p.AddCell(setTable_Cell_Bottom(bfChinese, string.Format("{0}", drt["QTY"]), Border_type_H, Font_Size, Element.ALIGN_RIGHT, 1, 2));          //退貨量
                    p.AddCell(setTable_Cell_Bottom(bfChinese, string.Format("{0}", ""), Border_type_H, Font_Size, Element.ALIGN_CENTER, 1, 2));                 //實退量
                    p.AddCell(setTable_Cell_Bottom(bfChinese, string.Format("{0}", drt["EA_UNIT"]), Border_type_H, Font_Size, Element.ALIGN_CENTER, 1, 2));     //單位
                    p.AddCell(setTable_Cell_Bottom(bfChinese, string.Format("{0}", ""), Border_type_H, Font_Size, Element.ALIGN_CENTER, 1, 2));                 //備註
                    p.AddCell(setTable_Cell_Bottom(bfChinese, string.Format("{0}", drt["ITEM_SEQ_NO"]), Border_type_H, Font_Size, Element.ALIGN_CENTER, 1, 1)); //序號
                    p.AddCell(setTable_Cell_Bottom(bfChinese, string.Format("{0}", drt["EA_BARCODE"]), Border_type_H, Font_Size, Element.ALIGN_LEFT, 1, 1));
                    #endregion
                }
                doc.Add(p);
                doc.Add(h_newline);

                //尾頁
                p = PageEnd(bfChinese, doc, h_newline, p, Font_Size);
                //簽收
                PageEndSign(bfChinese, row_Count_Now, row_page, pageEnd, Font_Size, p, Page, doc);
            }
            catch (Exception err)
            {
                returnstring += "發生錯誤\n";
                throw new Exception(err.Message);
            }
            finally
            {
                doc.Close();
            }

            return(returnstring);
        }
Esempio n. 8
0
        protected override void New_WSC_DLL_Form_Load(object sender, EventArgs e)
        {
            base.New_WSC_DLL_Form_Load(sender, e);
            panel_IKnow.Size     = new Size(844, 639);
            panel_IKnow.Location = new Point(61, 38);

            //取得此表單的LoaderFormInfo
            fFormInfo = XSC.ClientLoader.FormInfo(this);
            //透過LoginUserId取得sqlClientAccess
            sca = XSC.ClientAccess.UserAccess.sqlUserAccess(fFormInfo.LoginUserId);

            #region 帳號權限判斷
            Boolean IsCorrectUser = false, IsPXWMS_N = false, IsPXWMS_S = false, IsPXWMS_C = false;
            //取得工號
            string    cmdstring = "Select EMPID From XSC_Menu_Userlist where XSC_UserID=@userid";
            object[]  objParam  = { "@userid", SqlDbType.NVarChar.ToString(), fFormInfo.LoginUserId };
            DataTable dt_87     = sca.GetDataTable("EEPDC", cmdstring, objParam, 0);
            if (dt_87.Rows.Count > 0)
            {
                IsCorrectUser = true;
                UserWorkNum   = dt_87.Rows[0][0].ToString();
            }

            if (UserWorkNum != "")
            {
                //取得兩倉權限
                //觀音
                cmdstring = "select top 1 0 from employee_data where S_empd_id=@userid";
                object[]  objParam1  = { "@userid", SqlDbType.NVarChar.ToString(), UserWorkNum };
                DataTable dt_PXWMS_N = sca.GetDataTable("PXWMS_N", cmdstring, objParam1, 0);
                if (dt_PXWMS_N.Rows.Count > 0)
                {
                    IsPXWMS_N = true;
                }

                //岡山
                DataTable dt_PXWMS_S = sca.GetDataTable("PXWMS_S", cmdstring, objParam1, 0);
                if (dt_PXWMS_S.Rows.Count > 0)
                {
                    IsPXWMS_S = true;
                }

                //梧棲
                DataTable dt_PXWMS_C = sca.GetDataTable("PXWMS_C_Plus2", cmdstring, objParam1, 0);
                if (dt_PXWMS_C.Rows.Count > 0)
                {
                    IsPXWMS_C = true;
                }
            }

            if (IsPXWMS_N == false && IsPXWMS_S == false && IsPXWMS_C == false)
            {
                IsCorrectUser = false;
            }
            #endregion

            if (!IsCorrectUser)
            {
                MessageBox.Show("帳號無法對應三倉權限,請洽資訊部人員", ":<");
                SetMasterBindingNavigator(null);
                SetButtonEnable("L");
                return;
            }

            txb_ItemNo.Text = txb_Merdid.Text;
            SetMasterBindingNavigator(BS_Repl);
            SetButtonEnable("FL");
            if (IsPXWMS_N)
            {
                comboBox1.Items.Add(new Item("觀音", "PXWMS_N"));
            }
            if (IsPXWMS_S)
            {
                comboBox1.Items.Add(new Item("岡山", "PXWMS_S"));
            }
            if (IsPXWMS_C)
            {
                comboBox1.Items.Add(new Item("梧棲", "PXWMS_C_Plus2"));
            }
            comboBox1.Items.Add(new Item("測試", "PXWMS_200"));
            comboBox1.SelectedIndex = 0;

            cB_SFCkind.Items.Add(new Item("SFCXX01", "SFC%01"));
            cB_SFCkind.Items.Add(new Item("SFCXX02", "SFC%02"));
            cB_SFCkind.Items.Add(new Item("出貨暫存", "%%"));
            cB_SFCkind.Items.Add(new Item("任意儲位", "%%"));
            cB_SFCkind.SelectedIndex = 0;

            ResizeForm.ResizeForm.WSC_Resize(this, 1);

            gridControl1.DataSource = BS_Repl;
            DevExpressGridFunctions.GridviewSetup(gridView1);
            DevExpressGridFunctions.GridviewSetup(gridView2);
        }
Esempio n. 9
0
        static public string CreatPdf_Prod(XSC.ClientAccess.sqlClientAccess sca, string RJ, string siteno, string Host_string, string IP_string, string Mainfilepath)
        {
            string    returnstring = "";
            string    filepath     = Mainfilepath;
            string    path; //檔案路徑
            DataTable dt = new DataTable();

            try
            {
                #region  找PO單
                string sqlcommand =
                    @"select 
                SITE_NO_DESCR
                ,RJ_NO
                ,VENDOR_NO=VENDOR_NO+VENDOR_NAME
                ,ARRIVE_DATE=convert(varchar,ARRIVE_DATE,111)
                ,ARRIVE_START_DATE=convert(varchar,ARRIVE_DATE,111)+'~'+ convert(varchar,CLOSE_DATE,111)
                ,ARRIVE_START_TIME='('+ARRIVE_START_TIME+'-'+ARRIVE_END_TIME+')'
                ,ITEM_SEQ_NO
                ,ITEM_NO
                ,EA_BARCODE
                ,NAME
                ,QTY
                ,EA_UNIT
                from V_EDI_BACK_R02_T 
                where RJ_NO=@po_no and site_no=@site_no";
                object[] scaParam = { "@po_no",   "NVarChar", RJ,
                                      "@site_no", "NVarChar", siteno };
                dt           = sca.GetDataTable("EDI_DC", sqlcommand, scaParam, 0);
                dt.TableName = "V_EDI_BACK_R02_T";
                if (dt.Rows.Count == 0)
                {
                    returnstring += "找不到資料,請確認RJ單號存在";
                    return(returnstring);
                }
                #endregion

                XtraReport_RJ xReport1 = new XtraReport_RJ();
                xReport1.DataSource = dt;
                xReport1.DataMember = dt.TableName;

                path = filepath + "\\" + "RJ" + RJ + "_" + siteno + ".pdf";
                if (path != "")
                {
                    xReport1.ExportToPdf(path);

                    #region 記錄log
                    sqlcommand = "insert into RunLog (JobID,JobType,JobDate,JobCmd,Crt_date) "
                                 + " values('',"                       //JobID
                                 + "'手動產生PDF"                          //JobType
                                 + "',CONVERT(CHAR(10),GETDATE(),112)" //JobDate
                                 + ",'PDF_PO_Kota.exe " + RJ
                                 + "," + System.Security.Principal.WindowsIdentity.GetCurrent().Name
                                 + "," + Host_string
                                 + "," + IP_string  //JobCmd
                                 + "',GETDATE()) "; //Crt_date
                    sca.Update("LGDC", sqlcommand, scaParam, 0);
                    #endregion

                    returnstring += "PDF產生完成  " + path;
                }
                else
                {
                    returnstring += RJ + "  路徑有誤,請重新產生";
                }
            }
            catch (Exception err)
            {
                returnstring += "發生錯誤\n" + err.Message + "\n";
                //throw new Exception(err.Message);
            }
            finally
            {
            }
            return(returnstring);
        }
Esempio n. 10
0
        static public string CreatPdf_Prod(XSC.ClientAccess.sqlClientAccess sca, string PO, string siteno, string Host_string, string IP_string, string Mainfilepath)
        {
            string    returnstring = "";
            string    filepath     = Mainfilepath;
            string    path; //檔案路徑
            DataTable dt = new DataTable();

            try
            {
                #region  找PO單
                string sqlcommand =
                    @"
                select 
                SITE_NO_Descr=SITE_NO_Descr+'['+DOCK_MODE_Descr+']',
                PO_NO,
                VENDOR_NO=VENDOR_NO+VENDOR_Name,
                ARRIVE_DATE,
                ARRIVE_START_TIME=ARRIVE_START_TIME+'-'+ARRIVE_END_TIME,
                RECEIVE_PLACE_ADDR,
                remark,
                remark2,
                SITE_NO,
                ITEM_SEQ_NO,
                ITEM_NO=ITEM_NO+CASE WHEN WARM_LAYER!='' THEN '('+WARM_LAYER+')' ELSE '' END,
                NAME,
                QTY,
                IP_QTY,
                WARM_LAYER,

                EA_Barcode,
                INNER_QTY,
                MANUFACTURING_DAYS=CASE WHEN MANUFACTURING_DAYS=MATURITIES_DAYS THEN '無保存期限' ELSE Replace(MATURITIES_DAYS,'/','') END,
                MATURITIES_DAYS=CASE WHEN MANUFACTURING_DAYS=MATURITIES_DAYS THEN '' ELSE Replace(MATURITIES_DAYS,'/','') END,
                IP_Barcode,

                CS_Barcode,
                Packing_memo,
                Carton_QTY=convert(varchar,Carton_QTY)+CS_UNIT,
                VENDOR_ITEM_NO,
                TI=convert(varchar,TI)+'底/'+convert(varchar,HI)+'高',
                TotalCase
                from v_T_PO 
                where PO_NO=@po_no 
                and site_no=@site_no";
                object[] scaParam = { "@po_no",   "NVarChar", PO,
                                      "@site_no", "NVarChar", siteno };
                dt           = sca.GetDataTable("EDI_DC", sqlcommand, scaParam, 0);
                dt.TableName = "v_T_PO";
                if (dt.Rows.Count == 0)
                {
                    returnstring += "找不到資料,請確認PO單號存在";
                    return(returnstring);
                }
                #endregion

                XtraReport_PO xReport1 = new XtraReport_PO();
                xReport1.DataSource = dt;
                xReport1.DataMember = dt.TableName;

                path = filepath + "\\" + PO + "_" + siteno + ".pdf";
                if (path != "")
                {
                    xReport1.ExportToPdf(path);

                    #region 記錄log
                    sqlcommand = "insert into RunLog (JobID,JobType,JobDate,JobCmd,Crt_date) "
                                 + " values('',"                       //JobID
                                 + "'手動產生PDF"                          //JobType
                                 + "',CONVERT(CHAR(10),GETDATE(),112)" //JobDate
                                 + ",'PDF_PO_Kota.exe " + PO
                                 + "," + System.Security.Principal.WindowsIdentity.GetCurrent().Name
                                 + "," + Host_string
                                 + "," + IP_string  //JobCmd
                                 + "',GETDATE()) "; //Crt_date
                    sca.Update("LGDC", sqlcommand, scaParam, 0);
                    #endregion

                    returnstring += "PDF產生完成  " + path;
                }
                else
                {
                    returnstring += PO + "  路徑有誤,請重新產生";
                }
            }
            catch (Exception err)
            {
                returnstring += "發生錯誤\n" + err.Message + "\n";
                //throw new Exception(err.Message);
            }
            finally
            {
            }
            return(returnstring);
        }
Esempio n. 11
0
        protected override void New_WSC_DLL_Form_Load(object sender, EventArgs e)
        {
            base.New_WSC_DLL_Form_Load(sender, e);

            //批次的解說文
            toolTip1.SetToolTip(txb_SupdId, "輸入完供應商代號, 按下Tab");
            cmb_BatchID.SelectedIndex = 0;

            //取得此表單的LoaderFormInfo
            fFormInfo = XSC.ClientLoader.FormInfo(this);
            //透過LoginUserId取得sqlClientAccess
            sca = XSC.ClientAccess.UserAccess.sqlUserAccess(fFormInfo.LoginUserId);

            #region 帳號權限判斷
            Boolean IsCorrectUser = false;
            bool    IsPXWMS_N = false, IsPXWMS_S = false, IsPXWMS_C = false;
            //取得工號
            string    cmdstring = "Select EMPID From XSC_Menu_Userlist where XSC_UserID=@userid";
            object[]  objParam  = { "@userid", SqlDbType.NVarChar.ToString(), fFormInfo.LoginUserId };
            DataTable dt_87     = sca.GetDataTable("EEPDC", cmdstring, objParam, 0);
            if (dt_87.Rows.Count > 0)
            {
                IsCorrectUser = true;
                UserWorkNum   = dt_87.Rows[0][0].ToString();
            }

            if (UserWorkNum != "")
            {
                //取得兩倉權限
                //觀音
                cmdstring = "select top 1 0 from employee_data where S_empd_id=@userid";
                object[]  objParam1  = { "@userid", SqlDbType.NVarChar.ToString(), UserWorkNum };
                DataTable dt_PXWMS_N = sca.GetDataTable("PXWMS_N", cmdstring, objParam1, 0);
                if (dt_PXWMS_N.Rows.Count > 0)
                {
                    IsPXWMS_N = true;
                }

                //岡山
                DataTable dt_PXWMS_S = sca.GetDataTable("PXWMS_S", cmdstring, objParam1, 0);
                if (dt_PXWMS_S.Rows.Count > 0)
                {
                    IsPXWMS_S = true;
                }

                //梧棲
                DataTable dt_PXWMS_C = sca.GetDataTable("PXWMS_C_Plus2", cmdstring, objParam1, 0);
                if (dt_PXWMS_C.Rows.Count > 0)
                {
                    IsPXWMS_C = true;
                }
            }

            if (IsPXWMS_N == false && IsPXWMS_S == false && IsPXWMS_C == false)
            {
                IsCorrectUser = false;
            }
            #endregion

            if (!IsCorrectUser)
            {
                MessageBox.Show("帳號無法對應三倉權限,請洽資訊部人員", ":<");
                SetMasterBindingNavigator(null);
                SetButtonEnable("L");
                return;
            }

            #region 設定新刪修會用到的物件
            List <object> Enable_objlist = new List <object>();
            Enable_objlist.Add(gridControl1);
            this.MasterObj = Enable_objlist;
            #endregion

            SetMasterBindingNavigator(BS_Repl);
            SetButtonEnable("FL EX help");

            #region  限對應三倉
            bindingNavigatorEditButton.Text = "重新產生資料(&E)";
            if (IsPXWMS_N)
            {
                cmb_SiteNo.Items.Add(new Item("觀音", "PXWMS_N"));
            }
            if (IsPXWMS_S)
            {
                cmb_SiteNo.Items.Add(new Item("岡山", "PXWMS_S"));
            }
            if (IsPXWMS_C)
            {
                cmb_SiteNo.Items.Add(new Item("梧棲", "PXWMS_C_Plus2"));
            }
            cmb_SiteNo.SelectedIndex = 0;
            #endregion

            ResizeForm.ResizeForm.WSC_Resize(this, 1);

            //gridControl1.DataSource = BS_Repl;
            dateTimePicker1.Value = DateTime.Now.AddDays(3);
            DevExpressGridFunctions.GridviewSetup(gridView1);
            DevExpressGridFunctions.GridviewSetup(gridView2);
            DevExpressGridFunctions.GridviewSetup(gridView3);
            btn_Close_panel1.ForeColor = Color.White;
            btn_Close_panel1.BackColor = Color.Red;
            Lbl_UserId.Text            = fFormInfo.LoginUserId;
            Lbl_WorkNum.Text           = UserWorkNum;
            Lbl_Version.Text           = "版本:" + FileVersionInfo.GetVersionInfo(Assembly.GetExecutingAssembly().Location).FileVersion.ToString();

            #region 獲取廠商清單
            DataTable dt_VendorList = GetSupdId();
            foreach (DataRow dr in dt_VendorList.Rows)
            {
                cmb_VendorNo.Items.Add(new Item(dr["NewAlias"].ToString(), dr["NewAlias"].ToString()));
            }
            #endregion
        }