Ejemplo n.º 1
0
        public JsonResult PrintSave(string Id)
        {
            NSession.Clear();
            PrintTemplateType obj = NSession.Get <PrintTemplateType>(Convert.ToInt32(Id));

            byte[] FormData = Request.BinaryRead(Request.TotalBytes);
            obj.Content = System.Text.Encoding.Default.GetString(FormData);
            NSession.Update(obj);
            NSession.Flush();
            return(Json(new { IsSuccess = 1 }));
        }
Ejemplo n.º 2
0
        public static PrintTemplate OfType(PrintTemplateType type)
        {
            switch (type)
            {
            case PrintTemplateType.Wide:
                return(new WidePrintTemplate());

            case PrintTemplateType.Standard:
                return(new StandardPrintTemplate());
            }
            return(null);
        }
Ejemplo n.º 3
0
 public ActionResult Edit(PrintTemplateType obj)
 {
     try
     {
         NSession.Update(obj);
         NSession.Flush();
     }
     catch (Exception ee)
     {
         return(Json(new { IsSuccess = false, ErrorMsg = "出错了" }));
     }
     return(Json(new { IsSuccess = true }));
 }
Ejemplo n.º 4
0
        /// <summary>
        /// 根据Id获取
        /// </summary>
        /// <param name="Id"></param>
        /// <returns></returns>
        public PrintTemplateType GetById(int Id)
        {
            PrintTemplateType obj = NSession.Get <PrintTemplateType>(Id);

            if (obj == null)
            {
                throw new Exception("返回实体为空");
            }
            else
            {
                return(obj);
            }
        }
Ejemplo n.º 5
0
 public JsonResult DeleteConfirmed(int id)
 {
     try
     {
         PrintTemplateType obj = GetById(id);
         NSession.Delete(obj);
         NSession.Flush();
     }
     catch (Exception ee)
     {
         return(Json(new { IsSuccess = false, ErrorMsg = "出错了" }));
     }
     return(Json(new { IsSuccess = true }));
 }
Ejemplo n.º 6
0
        private static void setPrintPurchaseData(PurchaseOrder item, DataGridView dataGridView2, PrintTemplateType type)
        {
            InteractResult <PrintTemplateInfo> result = CommonGlobalCache.ServerProxy.GetPrintTemplateInfo(type);

            //行列数基本不受限制,但超过一页失去意义,因为以Body为主,以其它为辅
            //   Header header = new Header(4, 2);
            //可以指定每页是否重复打印
            if (result.ExeResult == ExeResult.Success)
            {
                PrintTemplateInfo CurrentPTemplate = result.Data;
                for (int c = 0; c < CurrentPTemplate.PrintCount; c++)
                {
                    GoldPrinter.MisGoldPrinter misGoldPrinter = new GoldPrinter.MisGoldPrinter(false, new PrinterMargins(20, 20, 20, 20, 800, 1129));

                    if (CurrentPTemplate.OrderName != "")
                    {
                        //misGoldPrinter.Title = CurrentPTemplate.OrderName; //主标题(C#用\n表示换行)

                        ////this.CurrentPTemplate = PTemplateInfo;
                        //double headRow = Math.Round(Convert.ToSingle(CurrentPTemplate.SystemVariables.Count / 2));

                        //Header header = new Header(Convert.ToInt32(headRow) + 1, 2);



                        //header.IsDrawAllPage = true;

                        misGoldPrinter.Title = CurrentPTemplate.OrderName; //主标题(C#用\n表示换行)	}

                        misGoldPrinter.Caption = "";

                        double headRow = Math.Round(Convert.ToSingle(CurrentPTemplate.SystemVariables.Count / 2));

                        Header header = new Header(Convert.ToInt32(headRow) + 1, 2);
                        CommonGlobalUtil.WriteLog("变量总数=" + CurrentPTemplate.SystemVariables.Count + "\r\n" + "应显示行号=" + headRow);
                        header.IsDrawAllPage = true;
                        for (int i = 0; i < CurrentPTemplate.SystemVariables.Count; i++)
                        {
                            int curR = 0;
                            if (i < 2)
                            {
                                curR = 0;
                            }
                            else
                            {
                                double resRow = i / 2;
                                curR = Convert.ToInt32(Math.Round(resRow));
                            }
                            string KeyStr = "";
                            if (CurrentPTemplate.SystemVariables[i] == "采购单号")
                            {
                                KeyStr = "采购单号:";
                                header.SetText(curR, i % 2, CurrentPTemplate.SystemVariables[i] + item.ID);
                            }
                            else if (CurrentPTemplate.SystemVariables[i] == "开单时间")
                            {
                                KeyStr = "开单时间:";
                                header.SetText(curR, i % 2, KeyStr + item.CreateTime.GetDateTimeFormats('f')[0].ToString());
                            }
                            else if (CurrentPTemplate.SystemVariables[i] == "供应商")
                            {
                                KeyStr = "供 应 商:";
                                header.SetText(curR, i % 2, KeyStr + CommonGlobalCache.GetSupplierName(item.SupplierID));
                            }
                            else if (CurrentPTemplate.SystemVariables[i] == "操作人")
                            {
                                KeyStr = "操 作 人:";
                                header.SetText(curR, i % 2, KeyStr + CommonGlobalCache.GetUserName(item.AdminUserID));
                            }
                            else if (CurrentPTemplate.SystemVariables[i] == "总数量")
                            {
                                KeyStr = "总 数 量:";
                                header.SetText(curR, i % 2, KeyStr + item.TotalCount.ToString());
                            }
                            else if (CurrentPTemplate.SystemVariables[i] == "总成本")
                            {
                                KeyStr = "总 成 本:";
                                header.SetText(curR, i % 2, KeyStr + item.TotalCost.ToString());
                            }
                            else if (CurrentPTemplate.SystemVariables[i] == "单据备注")
                            {
                                KeyStr = "备    注:";
                                header.SetText(curR, i % 2, KeyStr + item.Remarks.ToString());
                            }
                        }

                        /*  header.SetText(0, 0, "采购单号:" + item.ID);
                         * header.SetText(0, 1, "开单时间:" + item.CreateTime.GetDateTimeFormats('f')[0].ToString());  //DataSource可以是字符串、一维数组、二维数组、DataTable、WinDataGrid、WebDataGrid、ListView\ListView、
                         * header.SetText(1, 0, "供 应 商:" + CommonGlobalCache.GetSupplierName(item.SupplierID));
                         * header.SetText(1, 1, "操 作 人:" + CommonGlobalCache.GetUserName(item.AdminUserID));               //同仁们还可以根据实际应用对GridBase的DataSource进行扩展
                         * header.SetText(2, 0, "总 数 量:" + item.TotalCount.ToString());
                         * header.SetText(2, 1, "总 成 本:" + item.TotalCost.ToString());                //同仁们还可以根据实际应用对GridBase的DataSource进行扩展
                         * header.SetText(3, 0, "备    注:");
                         * header.SetText(3, 1, item.Remarks);*/
                        misGoldPrinter.Header = header;
                        //misGoldPrinter.RowsPerPage
                        //Bottom bottom = new Bottom();
                        // bottom.DrawPrinterMargins

                        /*misGoldPrinter.DataSource = DataGridViewUtil.ToStringArray(dataGridView2, true, true);
                         * if (!Directory.Exists(CommonGlobalUtil.SystemDir + "EXPORTS\\"))
                         * {
                         *  Directory.CreateDirectory(CommonGlobalUtil.SystemDir + "EXPORTS\\");
                         * }
                         * misGoldPrinter.FileName = CommonGlobalUtil.SystemDir + "EXPORTS\\" + item.ID + ".jpg";
                         * ((GoldPrinter.Body)(misGoldPrinter.Body)).Font = dataGridView2.Font;
                         *
                         * //        int[] widths = new int[] {
                         * //    80,100,50,40,50,50,50,50,50,
                         * //    30,30,30,30,30,30,30,30,30,30,30
                         * //    ,40,50,50
                         * //};
                         * int[] widths = new int[CurrentPTemplate.PrintColumnInfos.Count];
                         * for (int j = 0; j < CurrentPTemplate.PrintColumnInfos.Count; j++)
                         * {
                         *  widths[j] = Convert.ToInt32(CurrentPTemplate.PrintColumnInfos[j].Rate);
                         * }
                         *
                         *
                         * //尺码固定的,但是他会变,那么怎么根据他的显示设置,
                         *
                         * List<int> widthList = new List<int>();
                         * List<int> columnCount = new List<int>();
                         * List<DataGridViewColumn> columns = new List<DataGridViewColumn>();
                         * List<PrintColumnInfo> dataGV = CurrentPTemplate.PrintColumnInfos;
                         * foreach (DataGridViewColumn col in dataGridView2.Columns)
                         * {
                         *  if (col.Tag?.ToString() != PrinterNoCount)
                         *  {
                         *      //  columns.Add(col);
                         *  }
                         *  if (dataGV.FindAll(t => t.Name == col.HeaderText).Count > 0)
                         *  {
                         *      columns.Add(col);
                         *
                         *  }
                         *    else
                         *    {
                         *      col.Visible = false;
                         *    }
                         *
                         *
                         *
                         * }
                         *
                         * for (int i = 0; i < columns.Count; i++)
                         * {
                         *  DataGridViewColumn column = columns[i];
                         *  if (column.Visible)
                         *  {
                         *      widthList.Add(widths[i]);
                         *  }
                         * }
                         *
                         * widths = widthList.ToArray();
                         * int newWidth = 800;
                         * //int totalWidth = 0;
                         * //for (int i = 0; i < widths.Length; i++)
                         * //{
                         * //    totalWidth += widths[i];
                         * //}
                         *
                         * for (int i = 0; i < widths.Length; i++)
                         * {
                         *  // widths[i] = decimal.ToInt32(Math.Round((widths[i] * newWidth * (decimal)0.1), 0, MidpointRounding.AwayFromZero));
                         *
                         *  widths[i] = decimal.ToInt32(Math.Round((widths[i] * 10 * (decimal)0.1), 0, MidpointRounding.AwayFromZero));
                         * }
                         * ((GoldPrinter.Body)(misGoldPrinter.Body)).ColsWidth = widths;
                         * misGoldPrinter.Preview();
                         * misGoldPrinter.Dispose();
                         * misGoldPrinter = null;*/
                        List <PrintColumnInfo> dataGV = CurrentPTemplate.PrintColumnInfos;
                        string ColumnsList            = string.Empty;
                        foreach (PrintColumnInfo itemC in dataGV)
                        {
                            ColumnsList += itemC.Name + ",";
                        }
                        CommonGlobalUtil.WriteLog("模板设置打印列表头为=" + ColumnsList + "\r\n");
                        bool isflag = false;
                        if (dataGV.Count == 0)
                        {
                            isflag = true;
                        }

                        List <int> columnCount         = new List <int>();
                        int        pinrtColNum         = 0;
                        string     dataGridColumnsList = string.Empty;
                        if (dataGridView2.Columns.Count > 0)
                        {
                            for (int i = 0; i < dataGridView2.Columns.Count; i++)
                            {
                                DataGridViewColumn column = dataGridView2.Columns[i];
                                //if (column.HeaderText == "F" || column.HeaderText == "XS" || column.HeaderText == "S" || column.HeaderText == "M" || column.HeaderText == "L"
                                //   || column.HeaderText == "XL" || column.HeaderText == "2XL" || column.HeaderText == "3XL" || column.HeaderText == "4XL" || column.HeaderText == "5XL"
                                //   || column.HeaderText == "6XL")
                                //{
                                //    if (dataGV.FindAll(t => t.Name == "尺码列").Count > 0)
                                //    {
                                //        columnCount.Add(i);
                                //    }
                                //    else
                                //    {
                                //        column.Visible = false;
                                //    }
                                //}
                                //else
                                //{
                                if (dataGV.FindAll(t => t.Name == column.HeaderText).Count > 0)
                                {
                                    columnCount.Add(i);
                                    dataGridColumnsList += column.HeaderText + ",";
                                    pinrtColNum++;
                                }
                                else
                                {
                                    if (dataGV.FindAll(t => t.Name == column.DataPropertyName).Count > 0)
                                    {
                                        columnCount.Add(i);
                                        column.HeaderText    = column.HeaderText.Replace("\r\n", " ");
                                        dataGridColumnsList += column.DataPropertyName + ",";
                                        pinrtColNum++;
                                    }
                                    else
                                    {
                                        if (column.DataPropertyName.Contains("XL"))
                                        {
                                            string name = column.DataPropertyName;  //XL3
                                                                                    //3XL
                                            string newname  = name.Replace("XL", "");
                                            string checkstr = newname + "XL";
                                            if (dataGV.FindAll(t => t.Name == checkstr).Count > 0)
                                            {
                                                columnCount.Add(i);
                                                column.HeaderText    = column.HeaderText.Replace("\r\n", " ");
                                                dataGridColumnsList += column.DataPropertyName + ",";
                                                pinrtColNum++;
                                            }
                                            else
                                            {
                                                column.Visible = false;
                                            }
                                        }
                                        else
                                        {
                                            column.Visible = false;
                                        }
                                    }
                                }
                                if (isflag)
                                {
                                    if (i == 0)
                                    {
                                        //打印设置模板不设置任何列,但由于MisGoldPrinter这个类的打印主体为DataGridView,所有必须设置一列默认空的
                                        columnCount.Add(i);
                                        column.Visible    = true;
                                        column.HeaderText = "";

                                        DataTable  dt = new DataTable();
                                        DataColumn c1 = new DataColumn();
                                        c1.ColumnName = "HeaderText";

                                        dt.Columns.Add(c1);
                                        dataGridView2.DataSource = null;
                                        dataGridView2.DataSource = dt;
                                    }
                                }
                                //}
                            }

                            CommonGlobalUtil.WriteLog("DataGridView能打印的列为=" + dataGridColumnsList);

                            misGoldPrinter.DataSource = DataGridViewUtil.ToStringArray(dataGridView2, true, true);
                            // misGoldPrinter.DataSource =   dataGridView2.DataSource;


                            if (!Directory.Exists(CommonGlobalUtil.SystemDir + "EXPORTS\\"))
                            {
                                Directory.CreateDirectory(CommonGlobalUtil.SystemDir + "EXPORTS\\");
                            }
                            misGoldPrinter.FileName = CommonGlobalUtil.SystemDir + "EXPORTS\\" + item.ID + ".jpg";
                            ((GoldPrinter.Body)(misGoldPrinter.Body)).Font = dataGridView2.Font;

                            /*  int[] widths = new int[] {
                             * 80,100,50,40, 50,
                             * 30,30,30,30,30,30,30,30,30,30,30
                             * ,40,50,50
                             * };*/
                            int[] widths = new int[CurrentPTemplate.PrintColumnInfos.Count];
                            for (int j = 0; j < CurrentPTemplate.PrintColumnInfos.Count; j++)
                            {
                                widths[j] = Convert.ToInt32(CurrentPTemplate.PrintColumnInfos[j].Rate);
                            }

                            /* List<int> widthList = new List<int>();
                             * for (int i = 0; i < CurrentPTemplate.PrintColumnInfos.Count; i++)
                             * {
                             *   DataGridViewColumn column = dataGridView2.Columns[columnCount[i]];
                             *   if (column.Visible && !String.IsNullOrEmpty(column.HeaderText))
                             *   {
                             *       widthList.Add(widths[i]);
                             *   }
                             *
                             * }*/
                            if (isflag)
                            {
                                widths    = new int[1];
                                widths[0] = 100;
                                /*   widthList.Add(widths[0]);*/
                            }

                            /*    widths = widthList.ToArray();*/
                            int newWidth = 800;

                            /*  int totalWidth = 0;
                             * for (int i = 0; i < widths.Length; i++)
                             * {
                             *    totalWidth += widths[i];
                             * }*/
                            //if (dataGridView2.Columns.Count > 0)
                            //{
                            for (int i = 0; i < widths.Length; i++)
                            {
                                widths[i] = decimal.ToInt32(Math.Round((widths[i] * newWidth * (decimal)0.1), 0, MidpointRounding.AwayFromZero));
                                // widths[i] = decimal.ToInt32(Math.Round((widths[i] * newWidth * (decimal)1.0 / totalWidth), 0, MidpointRounding.AwayFromZero));
                            }
                            CommonGlobalUtil.WriteLog("实际打印数量=" + pinrtColNum + "\r\n" + "设置能打印的列数量=" + widths.Length.ToString());
                            //misGoldPrinter.Bottom=
                            ((GoldPrinter.Body)(misGoldPrinter.Body)).ColsWidth = widths;
                            misGoldPrinter.Preview();
                            misGoldPrinter.Dispose();
                            //misGoldPrinter.Print();
                            misGoldPrinter = null;
                        }
                    }
                }
            }
        }
Ejemplo n.º 7
0
 private String GetTemplateDirectory(PrintTemplateType ptt)
 {
     string[] di = Directory.GetDirectories(Directory.GetCurrentDirectory(), "PrintTemplate");
     if (!di.Any())
         return string.Empty;
     string[] dii = Directory.GetDirectories(di[0], EnumHelper.GetDescription(ptt));
     if (!dii.Any())
         return string.Empty;
     return dii[0];
 }
Ejemplo n.º 8
0
 public List<string> GetTemplateNamesByType(PrintTemplateType ptt)
 {
     var templates = new List<string>();
     string templatePath = GetTemplateDirectory(ptt);
     if (templatePath == string.Empty)
         return templates;
     string[] fileNames = Directory.GetFiles(templatePath);
     if (!fileNames.Any())
         return templates;
     templates.AddRange(fileNames.Select(Path.GetFileName));
     return templates;
 }
Ejemplo n.º 9
0
        private static void setPrintDataGridView(RefundCostume item, DataGridView dataGridView2, PrintTemplateType type)
        {
            InteractResult <PrintTemplateInfo> result = CommonGlobalCache.ServerProxy.GetPrintTemplateInfo(type);

            //行列数基本不受限制,但超过一页失去意义,因为以Body为主,以其它为辅
            //   Header header = new Header(4, 2);
            //可以指定每页是否重复打印
            if (result.ExeResult == ExeResult.Success)
            {
                PrintTemplateInfo CurrentPTemplate = result.Data;
                for (int c = 0; c < CurrentPTemplate.PrintCount; c++)
                {
                    MisGoldPrinterOfReWrite misGoldPrinter = new MisGoldPrinterOfReWrite(false, new PrinterMargins(20, 20, 20, 20, 800, 1129));


                    misGoldPrinter.Title = CurrentPTemplate.OrderName; //主标题(C#用\n表示换行)	}

                    misGoldPrinter.Caption = "";

                    double headRow = Math.Round(Convert.ToSingle(CurrentPTemplate.SystemVariables.Count / 2));

                    Header header = new Header(Convert.ToInt32(headRow) + 1, 2);
                    // CommonGlobalUtil.WriteLog("变量总数=" + CurrentPTemplate.SystemVariables.Count + "\r\n" + "应显示行号=" + headRow);
                    header.IsDrawAllPage = true;
                    #region
                    Member _member = null;
                    if (item.RefundOrder.MemeberID != null)
                    {
                        _member = CommonGlobalCache.ServerProxy.GetOneMember(item.RefundOrder.MemeberID);
                    }
                    for (int i = 0; i < CurrentPTemplate.SystemVariables.Count; i++)
                    {
                        int curR = 0;
                        if (i < 2)
                        {
                            curR = 0;
                        }
                        else
                        {
                            double resRow = i / 2;
                            curR = Convert.ToInt32(Math.Round(resRow));
                        }
                        string KeyStr = "";
                        if (CurrentPTemplate.SystemVariables[i] == "销售单号")
                        {
                            KeyStr = "销售单号:";
                            header.SetText(curR, i % 2, CurrentPTemplate.SystemVariables[i] + ":" + item.RefundOrder.ID);
                        }
                        else if (CurrentPTemplate.SystemVariables[i] == "单据日期")
                        {
                            KeyStr = "单据日期:";
                            header.SetText(curR, i % 2, KeyStr + item.RefundOrder.CreateTime.GetDateTimeFormats('f')[0].ToString());
                        }
                        else if (CurrentPTemplate.SystemVariables[i] == "客户名称")
                        {
                            KeyStr = "客户名称:";
                            string userName = string.Empty;
                            if (_member != null)
                            {
                                userName = _member.Name;
                            }
                            header.SetText(curR, i % 2, KeyStr + userName);
                        }
                        else if (CurrentPTemplate.SystemVariables[i] == "客户电话")
                        {
                            KeyStr = "客户电话:";
                            string tel = string.Empty;
                            if (_member != null)
                            {
                                tel = _member.PhoneNumber;
                            }
                            header.SetText(curR, i % 2, KeyStr + tel);
                        }
                        else if (CurrentPTemplate.SystemVariables[i] == "客户地址")
                        {
                            KeyStr = "客户地址:";

                            string address = string.Empty;
                            if (_member != null)
                            {
                                address = _member.DetailAddress;
                            }
                            header.SetText(curR, i % 2, KeyStr + address);
                        }
                        else if (CurrentPTemplate.SystemVariables[i] == "操作人")
                        {
                            KeyStr = "操 作 人:";
                            header.SetText(curR, i % 2, KeyStr + CommonGlobalCache.GetUserName(item.RefundOrder.GuideID));
                        }
                        else if (CurrentPTemplate.SystemVariables[i] == "单据备注")
                        {
                            KeyStr = "备    注:";
                            header.SetText(curR, i % 2, KeyStr + item.RefundOrder.Remarks.ToString());
                        }
                    }
                    #endregion

                    misGoldPrinter.Header = header;

                    // List<PrintColumnInfo> dataGV = CurrentPTemplate.PrintColumnInfos;


                    List <PrintColumnInfo> dataGV           = new List <PrintColumnInfo>();
                    PrintColumnInfo        prinAutoIDColumn = new PrintColumnInfo();
                    prinAutoIDColumn.Name = "序列号";
                    prinAutoIDColumn.Rate = 5;
                    dataGV.Add(prinAutoIDColumn);
                    dataGV.AddRange(CurrentPTemplate.PrintColumnInfos);

                    string ColumnsList = string.Empty;
                    foreach (PrintColumnInfo itemC in dataGV)
                    {
                        ColumnsList += itemC.Name + ",";
                    }
                    CommonGlobalUtil.WriteLog("模板设置打印列表头为=" + ColumnsList + "\r\n");
                    //表格是否为零条记录
                    bool isflag = false;
                    if (dataGV.Count == 0)
                    {
                        isflag = true;
                    }

                    List <int> columnCount         = new List <int>();
                    int        pinrtColNum         = 0;
                    string     dataGridColumnsList = string.Empty;
                    if (dataGridView2.Columns.Count > 0)
                    {
                        for (int i = 0; i < dataGridView2.Columns.Count; i++)
                        {
                            DataGridViewColumn column = dataGridView2.Columns[i];

                            if (dataGV.FindAll(t => t.Name == column.HeaderText).Count > 0)
                            {
                                columnCount.Add(i);
                                dataGridColumnsList += column.HeaderText + ",";
                                pinrtColNum++;
                            }
                            else
                            {
                                if (dataGV.FindAll(t => t.Name == column.DataPropertyName).Count > 0)
                                {
                                    columnCount.Add(i);
                                    column.HeaderText    = column.HeaderText.Replace("\r\n", " ");
                                    dataGridColumnsList += column.DataPropertyName + ",";
                                    pinrtColNum++;
                                }
                                else
                                {
                                    if (column.DataPropertyName.Contains("XL"))
                                    {
                                        string name = column.DataPropertyName;  //XL3
                                                                                //3XL
                                        string newname  = name.Replace("XL", "");
                                        string checkstr = newname + "XL";
                                        if (dataGV.FindAll(t => t.Name == checkstr).Count > 0)
                                        {
                                            columnCount.Add(i);
                                            column.HeaderText    = column.HeaderText.Replace("\r\n", " ");
                                            dataGridColumnsList += column.DataPropertyName + ",";
                                            pinrtColNum++;
                                        }
                                        else
                                        {
                                            column.Visible = false;
                                        }
                                    }
                                    else
                                    {
                                        column.Visible = false;
                                    }
                                }
                            }
                            if (isflag)
                            {
                                if (i == 0)
                                {
                                    //打印设置模板不设置任何列,但由于MisGoldPrinter这个类的打印主体为DataGridView,所有必须设置一列默认空的
                                    columnCount.Add(i);
                                    column.Visible    = true;
                                    column.HeaderText = "";

                                    DataTable  dt = new DataTable();
                                    DataColumn c1 = new DataColumn();
                                    c1.ColumnName = "HeaderText";

                                    dt.Columns.Add(c1);
                                    dataGridView2.DataSource = null;
                                    dataGridView2.DataSource = dt;
                                }
                            }
                            //}
                        }

                        CommonGlobalUtil.WriteLog("DataGridView能打印的列为=" + dataGridColumnsList);


                        MultiHeader multiHeader = new MultiHeader(1, dataGV.Count);
                        for (int a = 0; a < dataGV.Count; a++)
                        {
                            multiHeader.SetText(0, a, dataGV[a].Name);
                        }


                        misGoldPrinter.DataSource        = DataGridViewUtil.ToStringArray(dataGridView2, false, true);
                        misGoldPrinter.RowsPerPage       = CurrentPTemplate.Rows + 1; //根据设置传值
                        misGoldPrinter.IsSubTotalPerPage = true;
                        int footerRowsNum = 0;
                        if (((GoldPrinter.Body)(misGoldPrinter.Body)).Rows >= 2)
                        {
                            footerRowsNum = ((GoldPrinter.Body)(misGoldPrinter.Body)).Rows;
                        }
                        else
                        {
                            footerRowsNum = 2;
                        }

                        Footer footer         = new Footer(footerRowsNum, dataGV.Count);
                        int    colIndex       = -1;
                        int    colIndexSecond = -1;
                        for (int b = 0; b < dataGV.Count; b++)
                        {
                            if (dataGV[b].Name == "金额")
                            {
                                colIndex = b;
                            }
                            if (dataGV[b].Name == "数量")
                            {
                                colIndexSecond = b;
                            }
                        }
                        string addressStr = string.Empty;
                        for (int a = 0; a < CurrentPTemplate.SystemVariables.Count; a++)
                        {
                            //if (dataGridView2.Rows.Count >= 2)
                            //{
                            if (CurrentPTemplate.SystemVariables[a] == "店铺地址")
                            {
                                Shop curShop = CommonGlobalCache.GetShop(item.RefundOrder.ShopID);
                                if (curShop != null)
                                {
                                    footer.SetText(0, 0, "店铺地址:" + curShop.Address);
                                }
                            }
                            if (CurrentPTemplate.SystemVariables[a] == "联系电话")
                            {
                                Shop curShop = CommonGlobalCache.GetShop(item.RefundOrder.ShopID);
                                if (curShop != null)
                                {
                                    footer.SetText(1, 0, "联系电话:" + curShop.PhoneNumber);
                                }
                            }
                            //}
                            //else if(dataGridView2.Rows.Count >= 1)
                            //{

                            //    if (CurrentPTemplate.SystemVariables[a] == "店铺地址")
                            //    {
                            //        if (item.RefundOrder.ShopID != null && item.RefundOrder.ShopID != "_online")
                            //        {
                            //            addressStr += "店铺地址:" + CommonGlobalCache.GetShop(item.RefundOrder.ShopID).Address;
                            //        }
                            //    }
                            //    if (CurrentPTemplate.SystemVariables[a] == "联系电话")
                            //    {
                            //        if (addressStr != string.Empty)
                            //        {
                            //            addressStr += "       ";
                            //        }
                            //        if (item.RefundOrder.ShopID != null && item.RefundOrder.ShopID != "_online")
                            //        {
                            //            addressStr += "联系电话:" + CommonGlobalCache.GetShop(item.RefundOrder.ShopID).PhoneNumber;
                            //        }
                            //    }

                            //}
                        }

                        //if (dataGridView2.Rows.Count == 1)
                        //{
                        //    footer.SetText(0, 0, addressStr);
                        //}
                        MoneyConvertChinese MConvertC = new MoneyConvertChinese();
                        //if (dataGridView2.Rows.Count > 1)
                        //{
                        //    footer.SetText(0, 0, "合计 金额大写 " + MConvertC.MoneyToChinese(item.RefundOrder.TotalMoneyReceived.ToString()));

                        //}
                        //else
                        //{
                        //    footer.SetText(0, 0, addressStr+ " 合计 金额大写 " + MConvertC.MoneyToChinese(item.RefundOrder.TotalMoneyReceived.ToString()));

                        //}

                        misGoldPrinter.EndSubTotalColsList = MConvertC.MoneyToChinese(item.RefundOrder.TotalMoneyReceived.ToString()) + ":" + item.RefundOrder.TotalMoneyReceived.ToString();
                        //  footer.SetText(0, 1, "合计:" + item.RefundOrder.TotalMoneyReceived);

                        /*  if (dataGridView2.Rows.Count > 1 )
                         * {
                         *    //if (dataGV.Count >= 2)
                         *    //{
                         *
                         *        footer.SetText(1, 1, "合计:" + item.RefundOrder.TotalMoneyReceived);
                         *    //}
                         *    //else
                         *    //{
                         *
                         *    //    footer.SetText(1, dataGV.Count, "合计:" + item.RefundOrder.TotalMoneyReceived);
                         *    //}
                         * }
                         * else
                         * {
                         *    //if (dataGV.Count >= 2)
                         *    //{
                         *        footer.SetText(0, 1, "合计:" + item.RefundOrder.TotalMoneyReceived);
                         *    //}
                         *    //else
                         *    //{
                         *
                         *    //    footer.SetText(0, dataGV.Count, "合计:" + item.RefundOrder.TotalMoneyReceived);
                         *    //}
                         * }*/

                        // PrinterBase pbase = footer.CalculatePageInfo();

                        //if (Math.Ceiling((decimal)dataGridView2.Rows.Count / CurrentPTemplate.Rows) > 1)
                        //{
                        //    footer.IsDrawAllPage = false;
                        //}
                        //else
                        //{

                        //    footer.IsDrawAllPage = true;
                        //}


                        misGoldPrinter.IsTotalIsDrawAllPage = false;
                        footer.IsDrawAllPage = false;


                        Bottom bottom = new Bottom();

                        bottom.IsDrawAllPage = true;

                        // bottom.TopMargin
                        // bottom.SetText("联系电话:"+CommonGlobalCache.GetShop(item.RetailOrder.ShopID).PhoneNumber);

                        misGoldPrinter.SubTotalColsList = (colIndex).ToString() + ";" + (colIndexSecond).ToString();      //用分号分隔的要求小计的列

                        /*   if (!Directory.Exists(CommonGlobalUtil.SystemDir + "EXPORTS\\"))
                         * {
                         * Directory.CreateDirectory(CommonGlobalUtil.SystemDir + "EXPORTS\\");
                         * }
                         * misGoldPrinter.FileName = CommonGlobalUtil.SystemDir + "EXPORTS\\" + item.RetailOrder.ID + ".jpg";*/
                        ((GoldPrinter.Body)(misGoldPrinter.Body)).Font = dataGridView2.Font;


                        int[] widths = new int[dataGV.Count];
                        for (int j = 0; j < dataGV.Count; j++)
                        {
                            widths[j] = Convert.ToInt32(dataGV[j].Rate);
                        }

                        List <int> widthList = new List <int>();

                        /*   for (int i = 0; i < CurrentPTemplate.PrintColumnInfos.Count; i++)
                         * {
                         *     DataGridViewColumn column = dataGridView2.Columns[columnCount[i]];
                         *     if (column.Visible && !String.IsNullOrEmpty(column.HeaderText))
                         *     {
                         *         widthList.Add(widths[i]);
                         *     }
                         *
                         * }*/
                        if (isflag)
                        {
                            widths    = new int[1];
                            widths[0] = 100;
                            // widthList.Add(widths[0]);
                        }

                        //   widths = widthList.ToArray();
                        int newWidth = 800;

                        /*  int totalWidth = 0;
                         * for (int i = 0; i < widths.Length; i++)
                         * {
                         *    totalWidth += widths[i];
                         * }*/
                        //if (dataGridView2.Columns.Count > 0)
                        //{
                        for (int i = 0; i < widths.Length; i++)
                        {
                            widths[i] = decimal.ToInt32(Math.Round((widths[i] * newWidth * (decimal)0.1), 0, MidpointRounding.AwayFromZero));
                            // widths[i] = decimal.ToInt32(Math.Round((widths[i] * newWidth * (decimal)1.0 / totalWidth), 0, MidpointRounding.AwayFromZero));
                        }
                        CommonGlobalUtil.WriteLog("实际打印数量=" + pinrtColNum + "\r\n" + "设置能打印的列数量=" + widths.Length.ToString());

                        /*    bottomFooter.ColsWidth = widths;*/
                        footer.ColsWidth      = widths;
                        misGoldPrinter.Footer = footer;
                        /* misGoldPrinter.BottomFooter = bottomFooter;*/
                        misGoldPrinter.Bottom      = bottom;
                        multiHeader.ColsWidth      = widths;
                        misGoldPrinter.MultiHeader = multiHeader;
                        multiHeader.ColsWidth      = widths;

                        ((GoldPrinter.Body)(misGoldPrinter.Body)).IsAverageColsWidth = false;
                        ((GoldPrinter.Body)(misGoldPrinter.Body)).ColsWidth          = widths;
                        misGoldPrinter.Preview();
                        misGoldPrinter.Dispose();
                        misGoldPrinter = null;
                    }
                }
            }
        }
 public ActionResult Edit(PrintTemplateType obj)
 {
     base.Update <PrintTemplateType>(obj);
     return(Json(new { IsSuccess = true }));
 }
 public JsonResult Create(PrintTemplateType obj)
 {
     base.Save <PrintTemplateType>(obj);
     return(Json(new { IsSuccess = true }));
 }
Ejemplo n.º 12
0
        private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            PrintTemplateType selectType = (PrintTemplateType)this.listBox1.SelectedValue;

            //if (selectType == PrintTemplateType.PurchaseIn)
            //{


            //}
            switch (selectType)
            {
            case PrintTemplateType.Retail:

                PrintOfSaleReturnTemplate tSaleReturn = new PrintOfSaleReturnTemplate();
                tSaleReturn.Dock = DockStyle.Fill;
                this.skinSplitContainer1.Panel2.Controls.Clear();
                this.skinSplitContainer1.Panel2.Controls.Add(tSaleReturn);
                break;

            case  PrintTemplateType.PurchaseIn:
                PrintOfPurchaseStock tPurchaseStock = new PrintOfPurchaseStock();
                tPurchaseStock.Dock = DockStyle.Fill;
                this.skinSplitContainer1.Panel2.Controls.Clear();
                this.skinSplitContainer1.Panel2.Controls.Add(tPurchaseStock);
                //   tPurchaseStock.Size.Height = this.Height;
                break;

            case PrintTemplateType.PurchaseOut:
                PrintOfPurchaseStockReturn tPurchaseReturnStock = new PrintOfPurchaseStockReturn();
                tPurchaseReturnStock.Dock = DockStyle.Fill;
                this.skinSplitContainer1.Panel2.Controls.Clear();
                this.skinSplitContainer1.Panel2.Controls.Add(tPurchaseReturnStock);

                break;


            case PrintTemplateType.AllocateOrder:
                PrintOfAllocateBill tPAllocateBill = new PrintOfAllocateBill();
                tPAllocateBill.Dock = DockStyle.Fill;
                this.skinSplitContainer1.Panel2.Controls.Clear();
                this.skinSplitContainer1.Panel2.Controls.Add(tPAllocateBill);
                break;

            case PrintTemplateType.CheckStoreOrder:
                PrintOfCheckStore tCheckStoreBill = new PrintOfCheckStore();
                tCheckStoreBill.Dock = DockStyle.Fill;
                this.skinSplitContainer1.Panel2.Controls.Clear();
                this.skinSplitContainer1.Panel2.Controls.Add(tCheckStoreBill);

                break;

            case PrintTemplateType.PfOrder:

                PrintOfPfSendBill tPPfSendBill = new PrintOfPfSendBill();
                tPPfSendBill.Dock = DockStyle.Fill;
                this.skinSplitContainer1.Panel2.Controls.Clear();
                this.skinSplitContainer1.Panel2.Controls.Add(tPPfSendBill);

                break;

            case PrintTemplateType.PfTOrder:

                PrintOfPtSendBill tPPtSendBill = new PrintOfPtSendBill();
                tPPtSendBill.Dock = DockStyle.Fill;
                this.skinSplitContainer1.Panel2.Controls.Clear();
                this.skinSplitContainer1.Panel2.Controls.Add(tPPtSendBill);

                break;

            case PrintTemplateType.ReplenishOrder:

                PrintOFreplenishBill tPFreplenishBill = new PrintOFreplenishBill();
                tPFreplenishBill.Dock = DockStyle.Fill;
                this.skinSplitContainer1.Panel2.Controls.Clear();
                this.skinSplitContainer1.Panel2.Controls.Add(tPFreplenishBill);
                break;

            case PrintTemplateType.DayReport:
                PrintOfBalanceOnThatDay tBalanceDay = new PrintOfBalanceOnThatDay();
                tBalanceDay.Dock = DockStyle.Fill;
                this.skinSplitContainer1.Panel2.Controls.Clear();
                this.skinSplitContainer1.Panel2.Controls.Add(tBalanceDay);

                break;

            default:
                break;
            }

            // InteractResult<PrintTemplateInfo> ptempInfo = GlobalCache.ServerProxy.GetPrintTemplateInfo(selectType);
            //if (ptempInfo.ExeResult == ExeResult.Success)
            //{
            //ptempInfo.Data.SystemVariable
            //dataGridViewPagingSumCtrl.BindingDataSource(ptempInfo.Data.SystemVariables);
            //                this.dataGridView1.DataSource = ptempInfo.Data.SystemVariables;
            //   SetUpShopView(ptempInfo.Data.SystemVariables);
            //  this.dataGridView2.DataSource = ptempInfo.Data.PrintColumnInfos;
            //}
            //else
            //{
            //    ShowMessage(ptempInfo.Msg);
            //}

            //GetPrintTemplateInfo
            //SavePrintTemplateInfo
        }
Ejemplo n.º 13
0
        public ActionResult Edit(int id)
        {
            PrintTemplateType obj = GetById(id);

            return(View(obj));
        }
Ejemplo n.º 14
0
 public PrintBatchHandler startNewBatch(PrintTemplateType printTemplateType)
 {
     return(new PrintBatchHandler(printTemplateType, this));
 }
        public ActionResult Edit(int id)
        {
            PrintTemplateType obj = base.Get <PrintTemplateType>(id);

            return(View(obj));
        }
Ejemplo n.º 16
0
 public PrintBatchHandler(PrintTemplateType templateType, PrintManager printManager)
 {
     _printBatch = new PrintBatch(PrintTemplate.OfType(templateType), printManager);
 }
Ejemplo n.º 17
0
 protected PrintTemplate(int imageCapacity, PrintTemplateType type)
 {
     _imageCapacity = imageCapacity;
     _type          = type;
 }