Esempio n. 1
0
 private void buttonPreview_Click_1(object sender, EventArgs e)
 {
     try
     {
         Condition condWarehouse = new Condition().AddCondition("warehouseId", GlobalData.Warehouse["id"]);
         var       previewData   = RestClient.Get <object[]>(Defines.ServerURL + "/warehouse/WMS_Template/stock_record/find_newest/" + condWarehouse.ToString());
         if (previewData == null)
         {
             return;
         }
         StandardFormPreviewExcel formPreviewExcel = new StandardFormPreviewExcel("盘点单预览");
         string no = "库存";
         if (!formPreviewExcel.AddPatternTable("Excel/StockRecord.xlsx", no))
         {
             return;
         }
         //formPreviewExcel.AddData("StockInfoCheckTicket", null, no);
         formPreviewExcel.AddData("StockRecord", previewData, no);
         formPreviewExcel.Show();
     }
     catch
     {
         MessageBox.Show("无任何数据!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
         return;
     }
 }
Esempio n. 2
0
        private void buttonPreview_Click(object sender, EventArgs e)
        {
            if (this.model1.SelectionRange == null)
            {
                MessageBox.Show("请选择要预览的结算条目!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            if (this.model1.SelectionRange.Rows != 1)
            {
                MessageBox.Show("请选择一项结算条目查看详情页!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            //List<int> ids = new List<int>();
            //for (int i = 0; i < this.model1.SelectionRange.Rows; i++)
            //{
            //    int curRow = this.model1.SelectionRange.Row + i;
            //    if (this.model1[curRow, "id"] == null) continue;
            //    ids.Add((int)this.model1[curRow, "id"]);
            //}
            int id            = (int)this.model1[this.model1.SelectionRange.Row, "id"];
            var storageCharge = this.model1[this.model1.SelectionRange.Row, "storageCharge"];
            var logisticFee   = this.model1[this.model1.SelectionRange.Row, "logisticFee"];
            var wholeFee      = (double)storageCharge + (double)logisticFee;
            JavaScriptSerializer serializer = new JavaScriptSerializer();
            //string strIDs = serializer.Serialize(ids);

            var previewData = RestClient.Get <List <object> >(Defines.ServerURL + "/warehouse/WMS_Template/summary_note/find/" + id);

            if (previewData == null)
            {
                return;
            }
            var priceDetails = previewData.ToArray();
            StandardFormPreviewExcel formPreviewExcel = new StandardFormPreviewExcel("查看物流详情");


            string no = "查看结算详情";

            if (!formPreviewExcel.AddPatternTable("Excel/SettlementDetails.xlsx", no))
            {
                return;
            }
            formPreviewExcel.AddData("priceDetails", priceDetails, no);
            formPreviewExcel.AddData("storageCharge", storageCharge, no);
            formPreviewExcel.AddData("logisticFee", logisticFee, no);
            formPreviewExcel.AddData("wholeFee", wholeFee, no);


            formPreviewExcel.Show();
        }
        private void buttonPreview_Click(object sender, EventArgs e)
        {
            if (this.model1.SelectionRange == null)
            {
                MessageBox.Show("请选择要预览的汇总单条目!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            if (this.model1.SelectionRange.Rows != 1)
            {
                MessageBox.Show("请选择一项汇总单条目查看物流详情!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            List <int> ids = new List <int>();

            for (int i = 0; i < this.model1.SelectionRange.Rows; i++)
            {
                int curRow = this.model1.SelectionRange.Row + i;
                if (this.model1[curRow, "id"] == null)
                {
                    continue;
                }
                ids.Add((int)this.model1[curRow, "id"]);
            }
            JavaScriptSerializer serializer = new JavaScriptSerializer();
            string strIDs = serializer.Serialize(ids);

            var previewData = RestClient.Get <List <IDictionary <string, object> > >(Defines.ServerURL + "/warehouse/WMS_Template/summary_note_item/preview/" + strIDs);

            if (previewData == null)
            {
                return;
            }
            StandardFormPreviewExcel formPreviewExcel = new StandardFormPreviewExcel("查看物流详情");

            foreach (IDictionary <string, object> entryAndItem in previewData)
            {
                IDictionary <string, object> summaryNoteItem = (IDictionary <string, object>)entryAndItem["summaryNoteItem"];
                object[] deliveryAmountDetails = (object[])entryAndItem["deliveryAmountDetails"];
                string   no = (string)summaryNoteItem["supplierName"];
                if (!formPreviewExcel.AddPatternTable("Excel/DeliveryDetails.xlsx", no))
                {
                    return;
                }
                formPreviewExcel.AddData("summaryNoteItem", summaryNoteItem, no);
                formPreviewExcel.AddData("deliveryAmountDetails", deliveryAmountDetails, no);
            }
            formPreviewExcel.Show();
        }
Esempio n. 4
0
 private void buttonPreview_Click(object sender, EventArgs e)
 {
     try
     {
         if (this.model1.SelectionRange == null)
         {
             MessageBox.Show("请选择要预览的盘点单!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
             return;
         }
         List <int> ids = new List <int>();
         for (int i = 0; i < this.model1.SelectionRange.Rows; i++)
         {
             int curRow = this.model1.SelectionRange.Row + i;
             if (this.model1[curRow, "id"] == null)
             {
                 continue;
             }
             ids.Add((int)this.model1[curRow, "id"]);
         }
         JavaScriptSerializer serializer = new JavaScriptSerializer();
         string strIDs      = serializer.Serialize(ids);
         var    previewData = RestClient.Get <List <IDictionary <string, object> > >(Defines.ServerURL + "/warehouse/WMS_Template/stocktaking_order/preview/" + strIDs);
         if (previewData == null)
         {
             return;
         }
         StandardFormPreviewExcel formPreviewExcel = new StandardFormPreviewExcel("盘点单预览");
         foreach (IDictionary <string, object> entryAndItem in previewData)
         {
             IDictionary <string, object> stockTakingOrder = (IDictionary <string, object>)entryAndItem["stockTakingOrderView"];
             object[] stockTakingOrderItem = (object[])entryAndItem["stockTakingOrderItems"];
             string   no = (string)stockTakingOrder["no"];
             if (!formPreviewExcel.AddPatternTable("Excel/StockInfoCheckTicket.xlsx", no))
             {
                 return;
             }
             formPreviewExcel.AddData("StockInfoCheckTicket", stockTakingOrder, no);
             formPreviewExcel.AddData("StockInfoCheckTicketItem", stockTakingOrderItem, no);
         }
         formPreviewExcel.Show();
     }
     catch
     {
         MessageBox.Show("无任何数据!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
         return;
     }
 }
Esempio n. 5
0
        private void buttonPreview_Click(object sender, EventArgs e)
        {
            if (this.model1.SelectionRange == null)
            {
                MessageBox.Show("请选择要预览的备货单!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            List <int> ids = new List <int>();

            for (int i = 0; i < this.model1.SelectionRange.Rows; i++)
            {
                int curRow = this.model1.SelectionRange.Row + i;
                if (this.model1[curRow, "id"] == null)
                {
                    continue;
                }
                ids.Add((int)this.model1[curRow, "id"]);
            }
            JavaScriptSerializer serializer = new JavaScriptSerializer();
            string strIDs = serializer.Serialize(ids);

            var previewData = RestClient.Get <List <IDictionary <string, object> > >(Defines.ServerURL + "/warehouse/WMS_Template/transfer_order/preview/" + strIDs);

            if (previewData == null)
            {
                return;
            }
            StandardFormPreviewExcel formPreviewExcel = new StandardFormPreviewExcel("移库单预览");

            foreach (IDictionary <string, object> entryAndItem in previewData)
            {
                IDictionary <string, object> transferOrder = (IDictionary <string, object>)entryAndItem["transferOrder"];
                object[] transferOrderItems = (object[])entryAndItem["transferOrderItems"];
                string   no = (string)transferOrder["no"];
                if (!formPreviewExcel.AddPatternTable("Excel/TransferOrderNote.xlsx", no))
                {
                    return;
                }
                formPreviewExcel.AddData("transferOrder", transferOrder, no);
                formPreviewExcel.AddData("transferOrderItems", transferOrderItems, no);
            }
            formPreviewExcel.Show();
        }
        private void buttonZhongDu_Click(object sender, EventArgs e)
        {
            StandardFormPreviewExcel formPreviewExcel = new StandardFormPreviewExcel("出库单预览");

            foreach (IDictionary <string, object> orderAndItem in previewData)
            {
                IDictionary <string, object> deliveryOrder = (IDictionary <string, object>)orderAndItem["deliveryOrder"];
                object[] deliveryOrderItems = (object[])orderAndItem["deliveryOrderItems"];
                string   no = (string)deliveryOrder["no"];
                if (!formPreviewExcel.AddPatternTable("Excel/patternPutOutStorageTicketZhongDu.xlsx", no))
                {
                    return;
                }
                formPreviewExcel.AddData("deliveryOrder", deliveryOrder, no);
                formPreviewExcel.AddData("deliveryOrderItems", deliveryOrderItems, no);
            }
            formPreviewExcel.Show();
            this.Close();
        }
        private void buttonZhongDuFlow_Click(object sender, EventArgs e)
        {
            StandardFormPreviewExcel formPreviewExcel = new StandardFormPreviewExcel("出库单预览");

            object[] deliveryOrderItems = null;
            foreach (IDictionary <string, object> orderAndItem in previewData)
            {
                IDictionary <string, object> deliveryOrder = (IDictionary <string, object>)orderAndItem["deliveryOrder"];
                object[] deliveryOrderItem = (object[])orderAndItem["deliveryOrderItems"];
                if (deliveryOrderItems == null)
                {
                    deliveryOrderItems = deliveryOrderItem;
                }
                else
                {
                    deliveryOrderItems = deliveryOrderItems.Concat(deliveryOrderItem).ToArray();
                }
            }
            formPreviewExcel.AddPatternTable("Excel/patternPutOutStorageTicketZhongDuFlow.xlsx");
            formPreviewExcel.AddData("deliveryOrderItems", deliveryOrderItems);
            formPreviewExcel.Show();
            this.Close();
        }
Esempio n. 8
0
        private void toolStripButton1_Click(object sender, EventArgs e)
        {
            var worksheet = this.reoGridControlUser.Worksheets[0];
            StandardFormPreviewExcel formPreview = new StandardFormPreviewExcel("上架单预览");
            WMSEntities wmsEntities = new WMSEntities();

            int[] ids = Utilities.GetSelectedIDs(this.reoGridControlUser);
            if (ids.Length == 0)
            {
                MessageBox.Show("请选择一项预览", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            foreach (int id in ids)
            {
                try
                {
                    PutawayTicketView       putawayTicketView     = (from ptv in wmsEntities.PutawayTicketView where ptv.ID == id select ptv).FirstOrDefault();
                    PutawayTicketItemView[] putawayTicketItemView = (from ptiv in wmsEntities.PutawayTicketItemView where ptiv.PutawayTicketID == putawayTicketView.ID select ptiv).ToArray <PutawayTicketItemView>();
                    string worksheetName = id.ToString();
                    if (putawayTicketView == null)
                    {
                        MessageBox.Show("上架单不存在,请重新查询!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }
                    //ReceiptTicketView receiptTicketView = (from rtv in wmsEntities.ReceiptTicketView where rtv.ID == submissionTicketView.ReceiptTicketID select rtv).FirstOrDefault();
                    if (formPreview.AddPatternTable(@"Excel\PutawayTicket.xlsx", worksheetName) == false)
                    {
                        this.Close();
                        return;
                    }
                    if (putawayTicketView != null)
                    {
                        formPreview.AddData("PutawayTicket", putawayTicketView, worksheetName);
                    }
                    formPreview.AddData("PutawayTicketItem", putawayTicketItemView, worksheetName);
                    formPreview.SetPrintScale(1.0F, worksheetName);
                }
                catch
                {
                    MessageBox.Show("搜索失败,请检查网络连接!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }
            }
            formPreview.SetPrintedCallback(new Action(() =>
            {
                WMSEntities wmsEntities2 = new WMSEntities();
                foreach (int id in ids)
                {
                    PutawayTicket putawayTicket = (from pt in wmsEntities2.PutawayTicket where pt.ID == id select pt).FirstOrDefault();
                    if (putawayTicket != null)
                    {
                        if (putawayTicket.PrintTimes == null)
                        {
                            putawayTicket.PrintTimes = 0;
                        }
                        putawayTicket.PrintTimes++;
                    }
                }
                new Thread(() =>
                {
                    wmsEntities2.SaveChanges();
                    Search();
                }).Start();
            }));

            //formPreview.AddData("SubmissionTicketItem", submissionTicketItemView);
            formPreview.Show();
        }
        private void buttonADD_Click(object sender, EventArgs e)
        {
            this.buttonADD.Focus();
            int summaryMode = -1;
            var startTime   = this.model1[this.model1.SelectionRange.Row, "startTime"];
            var endTime     = this.model1[this.model1.SelectionRange.Row, "endTime"];

            try
            {
                string no = "";
                if (this.checkBoxChangeSummary.Checked == false)
                {
                    summaryMode = 1;
                    no          = "记录时间汇总";
                }
                else
                {
                    no = "业务时间汇总";
                }
                string body = "{\"warehouseId\":\"" + GlobalData.Warehouse["id"] + "\",\"checkMode\":\"" + summaryMode + "\",\"endTime\":\"" + endTime + "\",\"startTime\":\"" + startTime + "\"}";
                string url  = Defines.ServerURL + "/warehouse/" + GlobalData.AccountBook + "/account_record/summary_all_title";
                var    returnSummaryList = RestClient.RequestPost <List <object> >(url, body);
                var    returnSummarys    = returnSummaryList.ToArray();
                StandardFormPreviewExcel formPreviewExcel = new StandardFormPreviewExcel("账目汇总");


                if (!formPreviewExcel.AddPatternTable("Excel/AccountRecord.xlsx", no))
                {
                    return;
                }
                formPreviewExcel.AddData("returnSummarys", returnSummarys, no);
                formPreviewExcel.Show();


                //string localFilePath = ShowSaveFileDialog();

                //if (string.IsNullOrEmpty(localFilePath)) return;

                //DataTable dt = new DataTable();

                ////创建一个工作簿
                //IWorkbook workbook = new HSSFWorkbook();

                ////创建一个 sheet 表
                //ISheet sheet = workbook.CreateSheet(dt.TableName);

                ////创建一行
                //IRow rowH = sheet.CreateRow(0);

                ////创建一个单元格
                //ICell cell = null;

                ////创建单元格样式
                //ICellStyle cellStyle = workbook.CreateCellStyle();

                ////创建格式
                //IDataFormat dataFormat = workbook.CreateDataFormat();

                ////设置为文本格式,也可以为 text,即 dataFormat.GetFormat("text");
                //cellStyle.DataFormat = dataFormat.GetFormat("@");

                ////设置列名
                //foreach (DataColumn col in dt.Columns)
                //{
                //    //创建单元格并设置单元格内容
                //    rowH.CreateCell(col.Ordinal).SetCellValue(col.Caption);

                //    //设置单元格格式
                //    rowH.Cells[col.Ordinal].CellStyle = cellStyle;
                //}

                ////写入数据
                //for (int i = 0; i < dt.Rows.Count; i++)
                //{
                //    //跳过第一行,第一行为列名
                //    IRow row = sheet.CreateRow(i + 1);

                //    for (int j = 0; j < dt.Columns.Count; j++)
                //    {
                //        cell = row.CreateCell(j);
                //        cell.SetCellValue(dt.Rows[i][j].ToString());
                //        cell.CellStyle = cellStyle;
                //    }
                //}


                ////设置新建文件路径及名称
                //string savePath = localFilePath + DateTime.Now.ToString("yyyy-MM-dd-HH-mm-ss") + ".xls";

                ////创建文件
                //FileStream file = new FileStream(savePath, FileMode.CreateNew, FileAccess.Write);

                ////创建一个 IO 流
                //MemoryStream ms = new MemoryStream();

                ////写入到流
                //workbook.Write(ms);

                ////转换为字节数组
                //byte[] bytes = ms.ToArray();

                //file.Write(bytes, 0, bytes.Length);
                //file.Flush();



                ////释放资源
                //bytes = null;

                //ms.Close();
                //ms.Dispose();

                //file.Close();
                //file.Dispose();

                //workbook.Close();
                //sheet = null;
                //workbook = null;
            }
            catch (WebException ex)
            {
                string message = ex.Message;
                if (ex.Response != null)
                {
                    message = new StreamReader(ex.Response.GetResponseStream()).ReadToEnd();
                }
                MessageBox.Show("汇总失败:" + message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            this.Close();
        }