private void buttonZhongDuFlow_Click(object sender, EventArgs e)
        {
            StandardFormPreviewExcel formPreview = new StandardFormPreviewExcel("出库流水预览");

            WMSEntities wmsEntities = new WMSEntities();
            List <PutOutStorageTicketItemView> items = new List <PutOutStorageTicketItemView>();

            foreach (int id in putOutStorageTicketIDs)
            {
                PutOutStorageTicketItemView[] putOutStorageTicketItemViews =
                    (from p in wmsEntities.PutOutStorageTicketItemView
                     where p.PutOutStorageTicketID == id
                     select p).ToArray();
                items.AddRange(putOutStorageTicketItemViews);
            }
            if (formPreview.AddPatternTable(@"Excel\patternPutOutStorageTicketZhongDuFlow.xlsx") == false)
            {
                this.Close();
                return;
            }
            formPreview.AddData("putOutStorageTicketItems", items.ToArray());
            formPreview.SetPrintScale(1.2f);
            formPreview.Show();
            this.Close();
        }
Beispiel #2
0
        private void ShowPreview(bool qualifiedOnly)
        {
            JavaScriptSerializer serializer = new JavaScriptSerializer();
            string strIDs      = serializer.Serialize(inspectionNoteIDs);
            var    previewData = RestClient.Get <List <IDictionary <string, object> > >(Defines.ServerURL + "/warehouse/WMS_Template/inspection_note/preview/" + (qualifiedOnly ? "qualified/" : "") + strIDs);            if (previewData == null)
            {
                return;
            }
            StandardFormPreviewExcel formPreviewExcel = new StandardFormPreviewExcel("送检单预览" + (qualifiedOnly ? " - 仅合格条目" : ""));

            foreach (IDictionary <string, object> noteAndItem in previewData)
            {
                IDictionary <string, object> inspectionNote = (IDictionary <string, object>)noteAndItem["inspectionNote"];
                object[] inspectionNoteItems = (object[])noteAndItem["inspectionNoteItems"];
                string   no = (string)inspectionNote["no"];
                if (!formPreviewExcel.AddPatternTable("Excel/InspectionNote.xlsx", no))
                {
                    return;
                }
                formPreviewExcel.AddData("inspectionNote", inspectionNote, no);
                formPreviewExcel.AddData("inspectionNoteItems", inspectionNoteItems, no);
                formPreviewExcel.SetPrintScale(0.8f, no);
            }
            formPreviewExcel.Show();
            this.Close();
        }
        private void buttonCover_Click(object sender, EventArgs e)
        {
            StandardFormPreviewExcel formPreview = new StandardFormPreviewExcel("发货单预览");
            WMSEntities wmsEntities = new WMSEntities();

            foreach (int id in this.putOutStorageTicketIDs)
            {
                PutOutStorageTicketView       putOutStorageTicketView      = null;
                ShipmentTicketView            shipmentTicketView           = null;
                PutOutStorageTicketItemView[] putOutStorageTicketItemViews = null;
                try
                {
                    putOutStorageTicketView = (from p in wmsEntities.PutOutStorageTicketView
                                               where p.ID == id
                                               select p).FirstOrDefault();
                    putOutStorageTicketItemViews =
                        (from p in wmsEntities.PutOutStorageTicketItemView
                         where p.PutOutStorageTicketID == putOutStorageTicketView.ID
                         select p).ToArray();
                    if (putOutStorageTicketView == null)
                    {
                        MessageBox.Show("出库单" + putOutStorageTicketView.No + "不存在,可能已被删除,请重新查询!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }
                    shipmentTicketView =
                        wmsEntities.Database.SqlQuery <ShipmentTicketView>(string.Format(@"SELECT * FROM ShipmentTicketView WHERE ID = 
                                                                    (SELECT ShipmentTicketID FROM JobTicket
                                                                    WHERE JobTicket.ID = {0})", putOutStorageTicketView.JobTicketID)).FirstOrDefault();
                }
                catch
                {
                    MessageBox.Show("加载失败,请检查网络连接!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                string worksheetName = id.ToString();
                if (formPreview.AddPatternTable(@"Excel\patternPutOutStorageTicketNormal.xlsx", worksheetName) == false)
                {
                    this.Close();
                    return;
                }
                formPreview.AddData("putOutStorageTicket", putOutStorageTicketView, worksheetName);
                formPreview.AddData("putOutStorageTicketItems", putOutStorageTicketItemViews, worksheetName);
                formPreview.AddData("shipmentTicket", shipmentTicketView, worksheetName);
                formPreview.SetPrintScale(0.9F, worksheetName);
            }
            formPreview.Show();
            this.Close();
        }
        private void buttonAll_Click(object sender, EventArgs e)
        {
            WMSEntities wmsEntities = new WMSEntities();
            StandardFormPreviewExcel standardFormPreviewExcel = new StandardFormPreviewExcel("送检单预览");

            SubmissionTicket[] submissionTicket = idsToSubmissionTickets(this.ids);
            try
            {
                foreach (SubmissionTicket st in submissionTicket)
                {
                    string worksheetName = st.ID.ToString();
                    SubmissionTicketView       submissionTicketView     = (from stv in wmsEntities.SubmissionTicketView where stv.ID == st.ID select stv).FirstOrDefault();
                    SubmissionTicketItemView[] submissionTicketItemView =
                        (from p in wmsEntities.SubmissionTicketItemView
                         where p.SubmissionTicketID == st.ID
                         select p).ToArray();
                    ReceiptTicketView receiptTicketView = (from rt in wmsEntities.ReceiptTicketView where rt.ID == st.ReceiptTicketID select rt).FirstOrDefault();
                    if (standardFormPreviewExcel.AddPatternTable(@"Excel\SubmissionTicket.xlsx", worksheetName) == false)
                    {
                        this.Close();
                        return;
                    }
                    if (st != null)
                    {
                        standardFormPreviewExcel.AddData("SubmissionTicket", submissionTicketView, worksheetName);
                    }
                    if (receiptTicketView != null)
                    {
                        standardFormPreviewExcel.AddData("ReceiptTicket", receiptTicketView, worksheetName);
                    }
                    standardFormPreviewExcel.AddData("SubmissionTicketItem", submissionTicketItemView, worksheetName);
                    standardFormPreviewExcel.SetPrintScale(0.82f, worksheetName);
                }
                standardFormPreviewExcel.Show();
                this.Close();
            }
            catch
            {
                MessageBox.Show("无法连接到数据库,请查看网络连接!", "警告", MessageBoxButtons.YesNo, MessageBoxIcon.Error);
                return;
            }

            //StartPreview(submissionTicketItemView);
        }