Пример #1
0
 /// <summary>
 /// 数据打印
 /// </summary>
 /// <param name="printData"></param>
 public virtual void InvoicePrint(PrintDataClass printData)
 {
     PrintDocument document = new PrintDocument();
     //this.PrintData = printData;
     Margins margins = new Margins(this.DanToPex(0.5M), this.DanToPex(0.5M), this.DanToPex(0.5M),
         this.DanToPex(0.5M));
     document.DefaultPageSettings.Margins = margins;
     PaperSize size = new PaperSize("First custom size", this.DanToPex(PageSizeW), this.DanToPex(PageSizeH));
     document.DefaultPageSettings.PaperSize = size;
     document.PrintController = new StandardPrintController();
     document.PrintPage += new PrintPageEventHandler(this.pd_PrintPage);
     try
     {
         document.Print();
         LogHelper.WriteLog("过磅编号为:" + GetTextDate() + "。数据打印成功!");
     }
     catch (Exception e)
     {
         document.PrintController.OnEndPrint(document, new PrintEventArgs());
         LogHelper.WriteLog(LogHelper.GetCurSourceFileName() + "~" + LogHelper.GetLineNum() + "打印失败!", e);
     }
     finally
     {
         this.printData = null;
     }
 }
Пример #2
0
        /// <summary>
        /// 数据打印
        /// </summary>
        /// <param name="printData"></param>
        public virtual void InvoicePrint(PrintDataClass printData)
        {
            PrintDocument document = new PrintDocument();
            //this.PrintData = printData;
            Margins margins = new Margins(this.DanToPex(0.5M), this.DanToPex(0.5M), this.DanToPex(0.5M),
                                          this.DanToPex(0.5M));

            document.DefaultPageSettings.Margins = margins;
            PaperSize size = new PaperSize("First custom size", this.DanToPex(PageSizeW), this.DanToPex(PageSizeH));

            document.DefaultPageSettings.PaperSize = size;
            document.PrintController = new StandardPrintController();
            document.PrintPage      += new PrintPageEventHandler(this.pd_PrintPage);
            try
            {
                document.Print();
                LogHelper.WriteLog("过磅编号为:" + GetTextDate() + "。数据打印成功!");
            }
            catch (Exception e)
            {
                document.PrintController.OnEndPrint(document, new PrintEventArgs());
                LogHelper.WriteLog(LogHelper.GetCurSourceFileName() + "~" + LogHelper.GetLineNum() + "打印失败!", e);
            }
            finally
            {
                this.printData = null;
            }
        }
 public virtual void LoadWeightPaintDocument(Graphics g, PrintDataClass pdc, string PrintTitle)
 {
 }
        public override void LoadWeightPaintDocument(Graphics g, PrintDataClass pdc, string PrintTitle)
        {
            FontStyle bold    = FontStyle.Bold;
            Font      font    = new Font("黑体", 22f, bold);
            FontStyle regular = FontStyle.Regular;
            Font      font2   = new Font("宋体", 11f, regular, GraphicsUnit.Point);
            FontStyle style   = FontStyle.Regular;
            Font      font3   = new Font("宋体", 14f, style, GraphicsUnit.Point);
            FontStyle style4  = FontStyle.Bold;
            Font      font4   = new Font("宋体", 11f, style4, GraphicsUnit.Point);
            FontStyle italic  = FontStyle.Italic;

            italic |= FontStyle.Bold;
            Font         font5  = new Font("宋体", 10f, italic, GraphicsUnit.Point);
            FontStyle    style6 = FontStyle.Regular;
            Font         font6  = new Font("宋体", 11f, style6, GraphicsUnit.Point);
            FontStyle    style7 = FontStyle.Regular;
            Font         font7  = new Font("宋体", 10f, style7, GraphicsUnit.Point);
            StringFormat format = new StringFormat
            {
                LineAlignment = StringAlignment.Center
            };

            g.DrawString(pdc.CollName, font2, Brushes.Black, (PointF)base.GetPoint(base.m_Rect_x + 3.2M, base.m_Rect_y + 0.1m));
            g.DrawString(pdc.TradeID, font4, Brushes.Black, (PointF)base.GetPoint(base.m_Rect_x + 11.8M, base.m_Rect_y++));
            // g.DrawString(pdc.CollName, font2, Brushes.Black, (PointF)base.GetPoint(base.m_Rect_x + 3.2M, decimal.op_Decrement(base.m_Rect_y)));
            // g.DrawString(pdc.TradeID, font4, Brushes.Black, (PointF)base.GetPoint(base.m_Rect_x + 11.8M, decimal.op_Decrement(base.m_Rect_y)));
            decimal num = 0.0M;

            g.DrawString(pdc.CollName, font2, Brushes.Black, (PointF)base.GetPoint((base.m_Rect_x + base.m_decX) + base.m_First_Column_W, (base.m_Rect_y + num) + base.m_decY));
            g.DrawString(pdc.CarNo, font2, Brushes.Black, (PointF)base.GetPoint((((base.m_Rect_x + base.m_First_Column_W) + base.m_Second_Column_W) + base.m_Third_Column_W) + base.m_decX, (base.m_Rect_y + num) + base.m_decY));
            num = base.m_LineHeight * 1M;
            g.DrawString(pdc.NavicertCode, font2, Brushes.Black, (PointF)base.GetPoint((base.m_Rect_x + base.m_decX) + base.m_First_Column_W, (base.m_Rect_y + num) + base.m_decY));
            g.DrawString(pdc.LoadWeight.ToString(), font2, Brushes.Black, (PointF)base.GetPoint((((base.m_Rect_x + base.m_First_Column_W) + base.m_Second_Column_W) + base.m_Third_Column_W) + base.m_decX, (base.m_Rect_y + num) + base.m_decY));
            num = base.m_LineHeight * 2M;
            g.DrawString(pdc.MarkedCardCode, font2, Brushes.Black, (PointF)base.GetPoint((base.m_Rect_x + base.m_decX) + base.m_First_Column_W, (base.m_Rect_y + num) + base.m_decY));
            g.DrawString(pdc.EmptyWeight.ToString(), font2, Brushes.Black, (PointF)base.GetPoint((((base.m_Rect_x + base.m_First_Column_W) + base.m_Second_Column_W) + base.m_Third_Column_W) + base.m_decX, (base.m_Rect_y + num) + base.m_decY));
            num = base.m_LineHeight * 3M;
            g.DrawString(pdc.CoalKindName, font2, Brushes.Black, (PointF)base.GetPoint((base.m_Rect_x + base.m_decX) + base.m_First_Column_W, (base.m_Rect_y + num) + base.m_decY));
            g.DrawString(pdc.NetWeight.ToString(), font2, Brushes.Black, (PointF)base.GetPoint((((base.m_Rect_x + base.m_First_Column_W) + base.m_Second_Column_W) + base.m_Third_Column_W) + base.m_decX, (base.m_Rect_y + num) + base.m_decY));
            num = base.m_LineHeight * 4M;
            g.DrawString("残保金" + pdc.TaxCanBaoPayMoney.ToString("0.00"), font2, Brushes.Black, (PointF)base.GetPoint((base.m_Rect_x + base.m_decX) + base.m_First_Column_W, (base.m_Rect_y + num) + base.m_decY));
            g.DrawString("所得税" + pdc.TaxSuoDeShuiPayMoney.ToString("0.00"), font2, Brushes.Black, (PointF)base.GetPoint((((base.m_Rect_x + base.m_First_Column_W) + base.m_Second_Column_W) + base.m_Third_Column_W) + base.m_decX, (base.m_Rect_y + num) + base.m_decY));
            num = base.m_LineHeight * 5M;
            g.DrawString("排污费" + pdc.TaxSewagePayMoney.ToString("0.00"), font2, Brushes.Black, (PointF)base.GetPoint((base.m_Rect_x + base.m_decX) + base.m_First_Column_W, (base.m_Rect_y + num) + base.m_decY));
            g.DrawString("资源税" + pdc.TaxLocalPayMoney.ToString("0.00"), font2, Brushes.Black, (PointF)base.GetPoint((((base.m_Rect_x + base.m_First_Column_W) + base.m_Second_Column_W) + base.m_Third_Column_W) + base.m_decX, (base.m_Rect_y + num) + base.m_decY));
            num = base.m_LineHeight * 6M;
            g.DrawString("育林基金" + pdc.TaxYuLinPayMoney.ToString("0.00"), font2, Brushes.Black, (PointF)base.GetPoint((base.m_Rect_x + base.m_decX) + base.m_First_Column_W, (base.m_Rect_y + num) + base.m_decY));
            g.DrawString("水土保持" + pdc.TaxSoilWaterPayMoney.ToString("0.00"), font2, Brushes.Black, (PointF)base.GetPoint((((base.m_Rect_x + base.m_First_Column_W) + base.m_Second_Column_W) + base.m_Third_Column_W) + base.m_decX, (base.m_Rect_y + num) + base.m_decY));
            num = base.m_LineHeight * 7M;
            g.DrawString("销售单价" + pdc.CoalSaleUnitPrice.ToString("0.00"), font2, Brushes.Black, (PointF)base.GetPoint((base.m_Rect_x + base.m_decX) + base.m_First_Column_W, (base.m_Rect_y + num) + base.m_decY));
            g.DrawString("运输税" + pdc.TaxYunShuPayMoney.ToString("0.00"), font2, Brushes.Black, (PointF)base.GetPoint((((base.m_Rect_x + base.m_First_Column_W) + base.m_Second_Column_W) + base.m_Third_Column_W) + base.m_decX, (base.m_Rect_y + num) + base.m_decY));
            num = base.m_LineHeight * 8M;
            g.DrawString(pdc.PayCity, font2, Brushes.Black, (PointF)base.GetPoint((base.m_Rect_x + base.m_decX) + base.m_First_Column_W, (base.m_Rect_y + num) + base.m_decY));
            g.DrawString("销售收入" + (pdc.CoalSaleUnitPrice * Convert.ToDecimal(pdc.NetWeight.ToString())).ToString("0.00"), font2, Brushes.Black, (PointF)base.GetPoint((((base.m_Rect_x + base.m_First_Column_W) + base.m_Second_Column_W) + base.m_Third_Column_W) + base.m_decX, (base.m_Rect_y + num) + base.m_decY));
            num = base.m_LineHeight * 9M;
            string s = ConvertData.ConvertSum(pdc.PayMoney.ToString("0.00")) + " (¥" + pdc.PayMoney.ToString("0.00") + ")";

            g.DrawString(s, font2, Brushes.Black, (PointF)base.GetPoint((base.m_Rect_x + base.m_First_Column_W) + 0.1M, (base.m_Rect_y + num) + 0.7M));
            string str2 = "";

            if (pdc.PrintTimes > 1)
            {
                str2 = "此单据为发票补打票据";
            }
            g.DrawString(str2, font7, Brushes.Black, (PointF)base.GetPoint(base.m_Rect_x + 3.8M, (base.m_Rect_y + base.rect_H) + 0.2M));
            g.DrawString(pdc.LoadWeightTime, font7, Brushes.Black, (PointF)base.GetPoint(base.m_Rect_x + 12.3M, (base.m_Rect_y + base.rect_H) + 0.2M));
        }
Пример #5
0
        /// <summary>
        /// 根据文本中的过磅编号获取过磅数据并打印
        /// </summary>
        private void GetDBNew()
        {
            #region 根据过磅编号获取数据库中数据

            string NO = GetTextDate();
            if (string.IsNullOrEmpty(NO))
            {
                LogHelper.WriteLog(LogHelper.GetCurSourceFileName() + "~" + LogHelper.GetLineNum() + "过磅编号为空");
                return;
            }
            int dataBaseTime = Convert.ToInt32(AppConfig.ReadValue("setting", "DataBaseTime"));
            string tableName = AppConfig.ReadValue("setting", "tableName");
            string[] tableNames = tableName.Split(',');
            string sql = null;
            DataTable dtTable = null;
            foreach (string item in tableNames)
            {
                sql =
                "select top 1 * FROM [IndustryPlatform].[dbo].[" + item + "] where [WeightCode]='" + NO +
                "' order by WeightTime desc";
                //                string weightTimeBegin = DateTime.Now.AddSeconds(dataBaseTime).ToString("yyyy-MM-dd HH:mm:ss");
                //                string weightTimeEnd = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");

                try
                {
                    dtTable = SQLHelper.ExcuteDataTable(sql);
                }
                catch (Exception e)
                {
                    LogHelper.WriteLog(LogHelper.GetCurSourceFileName() + "~" + LogHelper.GetLineNum() + "获取过磅数据失败!", e);
                }
                if (dtTable != null && dtTable.Rows.Count > 0)//找到数据,跳出循环
                {
                    break;
                }
            }

            #endregion

            if (dtTable != null && dtTable.Rows.Count > 0)
            {

                #region 处理过磅数据

                try
                {
                    printData = new PrintDataClass();
                    this.printData.RoomName = dtTable.Rows[0]["RoomName"].ToString();
                    this.printData.TradeID = dtTable.Rows[0]["WeightCode"].ToString();
                    this.printData.CoalKindName = dtTable.Rows[0]["CoalKindName"].ToString();
                    this.printData.CollName = dtTable.Rows[0]["CollName"].ToString();
                    this.printData.MarkedCardCode = dtTable.Rows[0]["MarkedCardCode"].ToString();
                    this.printData.NavicertCode = dtTable.Rows[0]["NavicertCode"].ToString();
                    this.printData.CarNo = dtTable.Rows[0]["CarNo"].ToString();
                    this.printData.CarOwnerName = dtTable.Rows[0]["CarOwnerName"].ToString();
                    this.printData.CarType = dtTable.Rows[0]["CarType"].ToString();
                    this.printData.CollManager = dtTable.Rows[0]["Operator"].ToString();
                    this.printData.LoadWeight = dtTable.Rows[0]["LoadWeight"].ToString();
                    this.printData.NetWeight = dtTable.Rows[0]["NetWeight"].ToString();
                    this.printData.EmptyWeight = dtTable.Rows[0]["EmptyWeight"].ToString();
                    this.printData.IsBeatUp = true;
                    try
                    {
                        this.printData.CoalSaleUnitPrice = Convert.ToDecimal(dtTable.Rows[0]["PayUnitPirce"].ToString());
                    }
                    catch
                    {
                        this.printData.CoalSaleUnitPrice = 0;
                    }
                    this.printData.LoadWeightTime = dtTable.Rows[0]["WeightTime"].ToString();
                    this.printData.Operator = dtTable.Rows[0]["Operator"].ToString();
                }
                catch (Exception e)
                {
                    LogHelper.WriteLog(LogHelper.GetCurSourceFileName() + "~" + LogHelper.GetLineNum() + "处理过磅数据异常!", e);
                }

                #endregion

                #region 税费

                try
                {
                    SqlParameter sqlP_weightCode = new SqlParameter("@WeightCode", this.printData.TradeID);
                    DataTable dtTableMouney = SQLHelper.ExecSPDataSet("PT_LoadWeightTaxTwoPrint", sqlP_weightCode);

                    this.printData.TaxCounttryPayMoney = Convert.ToDecimal(dtTableMouney.Rows[0]["TaxCounttryPayMoney"]);
                    this.printData.TaxLocalPayMoney = Convert.ToDecimal(dtTableMouney.Rows[0]["TaxLocalPayMoney"]);
                    this.printData.TaxSewagePayMoney = Convert.ToDecimal(dtTableMouney.Rows[0]["TaxSewagePayMoney"]);
                    this.printData.TaxSoilWaterPayMoney =
                        Convert.ToDecimal(dtTableMouney.Rows[0]["TaxSoilWaterPayMoney"]);
                    this.printData.TaxesPrice = Convert.ToDecimal(dtTableMouney.Rows[0]["CoalSaleUnitPrice"]);
                    this.printData.TaxFundPayMoney = Convert.ToDecimal(dtTableMouney.Rows[0]["TaxFundPayMoney"]);
                    this.printData.TaxCanBaoPayMoney = Convert.ToDecimal(dtTableMouney.Rows[0]["TaxCanBaoPayMoney"]);
                    this.printData.TaxYuLinPayMoney = Convert.ToDecimal(dtTableMouney.Rows[0]["TaxYuLinPayMoney"]);
                    this.printData.TaxYunShuPayMoney = Convert.ToDecimal(dtTableMouney.Rows[0]["TaxYunShuPayMoney"]);
                    this.printData.PayMoney = Convert.ToDecimal(dtTableMouney.Rows[0]["TaxPayMoney"]);
                    this.printData.PrintTimes = 1;
                }
                catch (Exception e)
                {
                    LogHelper.WriteLog(LogHelper.GetCurSourceFileName() + "~" + LogHelper.GetLineNum() + "获取税费并加工异常!", e);
                }

                #endregion

                #region 销往目的地

                try
                {
                    string cityDataset = "select * from [TT_SalesCustomer] where SaleCode=@SaleCode";
                    SqlParameter sqlp_salecode = new SqlParameter("@SaleCode",
                        dtTable.Rows[0]["CustomerName"].ToString());
                    DataTable saleCityName = SQLHelper.ExcuteDataTable(cityDataset, sqlp_salecode);
                    if (saleCityName.Rows.Count > 0)
                    {
                        this.printData.PayCity = saleCityName.Rows[0]["SaleCustomer"].ToString();
                    }
                    else
                    {
                        this.printData.PayCity = "";
                    }
                }
                catch (Exception e)
                {
                    LogHelper.WriteLog(
                        LogHelper.GetCurSourceFileName() + "~" + LogHelper.GetLineNum() + "获取销往目的地数据异常!", e);
                }

                #endregion

                InvoicePrint(this.printData); //打印
                try
                {
                    if (File.Exists(filePath)) //打印完成后删除文件
                    {

                        FileInfo fi = new FileInfo(filePath);
                        if (fi.Attributes.ToString().IndexOf("ReadOnly") != -1)
                        {
                            fi.Attributes = FileAttributes.Normal;
                        }
                        File.Delete(filePath);
                    }
                }
                catch (Exception e)
                {
                    LogHelper.WriteLog(LogHelper.GetCurSourceFileName() + "~" + LogHelper.GetLineNum() + "文本删除失败!", e);
                }

            }
        }
Пример #6
0
        /// <summary>
        /// 获取数据库中指定的时间间隔(配置文件)过磅数据
        /// </summary>
        private void GetDB()
        {
            #region 获取数据库中数据

            int dataBaseTime = Convert.ToInt32(AppConfig.ReadValue("setting", "DataBaseTime"));
            string sql =
                "select top 1 * FROM [IndustryPlatform].[dbo].[TT_LoadWeight] where RoomCode=@RoomCode and WeightTime between @WeightTimeBegin and @WeightTimeEnd order by WeightTime desc";
            string weightTimeBegin = DateTime.Now.AddSeconds(dataBaseTime).ToString("yyyy-MM-dd HH:mm:ss");
            string weightTimeEnd = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
            SqlParameter[] sqlParameters =
                {
                    new SqlParameter("@WeightTimeBegin", weightTimeBegin),
                    new SqlParameter("@WeightTimeEnd", weightTimeEnd),
                    new SqlParameter("@RoomCode", AppConfig.ReadValue("setting", "RoomCode"))
                };
            DataTable dtTable = null;
            try
            {
                dtTable = SQLHelper.ExcuteDataTable(sql, sqlParameters);
            }
            catch (Exception e)
            {
                LogHelper.WriteLog(LogHelper.GetCurSourceFileName() + "~" + LogHelper.GetLineNum() + "获取过磅数据异常!", e);
            }

            #endregion

            if (dtTable != null && dtTable.Rows.Count > 0)
            {
                #region 过磅数据处理

                try
                {
                    printData = new PrintDataClass();
                    this.printData.RoomName = dtTable.Rows[0]["RoomName"].ToString();
                    this.printData.TradeID = dtTable.Rows[0]["WeightCode"].ToString();
                    this.printData.CoalKindName = dtTable.Rows[0]["CoalKindName"].ToString();
                    this.printData.CollName = dtTable.Rows[0]["CollName"].ToString();
                    this.printData.MarkedCardCode = dtTable.Rows[0]["MarkedCardCode"].ToString();
                    this.printData.NavicertCode = dtTable.Rows[0]["NavicertCode"].ToString();
                    this.printData.CarNo = dtTable.Rows[0]["CarNo"].ToString();
                    this.printData.CarOwnerName = dtTable.Rows[0]["CarOwnerName"].ToString();
                    this.printData.CarType = dtTable.Rows[0]["CarType"].ToString();
                    this.printData.CollManager = dtTable.Rows[0]["Operator"].ToString();
                    this.printData.LoadWeight = dtTable.Rows[0]["LoadWeight"].ToString();
                    this.printData.NetWeight = dtTable.Rows[0]["NetWeight"].ToString();
                    this.printData.EmptyWeight = dtTable.Rows[0]["EmptyWeight"].ToString();
                    this.printData.IsBeatUp = true;
                    this.printData.CoalSaleUnitPrice = Convert.ToDecimal(dtTable.Rows[0]["PayUnitPirce"].ToString());
                    this.printData.LoadWeightTime = dtTable.Rows[0]["WeightTime"].ToString();
                    this.printData.Operator = dtTable.Rows[0]["Operator"].ToString();
                }
                catch (Exception e)
                {
                    LogHelper.WriteLog(LogHelper.GetCurSourceFileName() + "~" + LogHelper.GetLineNum() + "过磅数加工据异常!", e);
                }

                #endregion

                #region 税费

                try
                {
                    SqlParameter sqlP_weightCode = new SqlParameter("@WeightCode", this.printData.TradeID);
                    DataTable dtTableMouney = SQLHelper.ExecSPDataSet("PT_LoadWeightTaxTwoPrint", sqlP_weightCode);

                    this.printData.TaxCounttryPayMoney = Convert.ToDecimal(dtTableMouney.Rows[0]["TaxCounttryPayMoney"]);
                    this.printData.TaxLocalPayMoney = Convert.ToDecimal(dtTableMouney.Rows[0]["TaxLocalPayMoney"]);
                    this.printData.TaxSewagePayMoney = Convert.ToDecimal(dtTableMouney.Rows[0]["TaxSewagePayMoney"]);
                    this.printData.TaxSoilWaterPayMoney = Convert.ToDecimal(dtTableMouney.Rows[0]["TaxSoilWaterPayMoney"]);
                    this.printData.TaxesPrice = Convert.ToDecimal(dtTableMouney.Rows[0]["CoalSaleUnitPrice"]);
                    this.printData.TaxFundPayMoney = Convert.ToDecimal(dtTableMouney.Rows[0]["TaxFundPayMoney"]);
                    this.printData.TaxCanBaoPayMoney = Convert.ToDecimal(dtTableMouney.Rows[0]["TaxCanBaoPayMoney"]);
                    this.printData.TaxYuLinPayMoney = Convert.ToDecimal(dtTableMouney.Rows[0]["TaxYuLinPayMoney"]);
                    this.printData.TaxYunShuPayMoney = Convert.ToDecimal(dtTableMouney.Rows[0]["TaxYunShuPayMoney"]);
                    this.printData.PayMoney = Convert.ToDecimal(dtTableMouney.Rows[0]["TaxPayMoney"]);
                    this.printData.PrintTimes = 1;
                }
                catch (Exception e)
                {
                    LogHelper.WriteLog(LogHelper.GetCurSourceFileName() + "~" + LogHelper.GetLineNum() + "税费获取或加工异常!", e);
                }

                //string sql_TaxItemDetail =
                //    "select * FROM [IndustryPlatform].[dbo].[VT_TaxItemDetail] where RoomCode=@RoomCode and CoalKindCode=@CoalKindCode";
                //SqlParameter[] sqlp_TaxItemDetail =
                //{
                //    new SqlParameter("@RoomCode", dtTable.Rows[0]["RoomCode"].ToString()),
                //    new SqlParameter("@CoalKindCode", dtTable.Rows[0]["CoalKindCode"].ToString()),
                //};
                //DataTable dtVT_TaxItemDetail = SQLHelper.ExcuteDataTable(sql_TaxItemDetail, sqlp_TaxItemDetail);
                //foreach (DataRow taxRow in dtVT_TaxItemDetail.Rows)
                //{
                //    switch (taxRow[1].ToString())
                //    {
                //        case "所得税":
                //            this.printData.TaxSuoDeShuiPayMoney = (Convert.ToDecimal(taxRow[2].ToString())*
                //                                                   Convert.ToDecimal(this.printData.NetWeight));
                //            break;
                //        case "资源税":
                //            this.printData.TaxLocalPayMoney = (Convert.ToDecimal(taxRow[2].ToString())*
                //                                               Convert.ToDecimal(this.printData.NetWeight));
                //            break;
                //        case "水土保持费":
                //            this.printData.TaxSoilWaterPayMoney = (Convert.ToDecimal(taxRow[2].ToString())*
                //                                                   Convert.ToDecimal(this.printData.NetWeight));
                //            break;
                //        case "育林基金":
                //            this.printData.TaxYuLinPayMoney = (Convert.ToDecimal(taxRow[2].ToString())*
                //                                               Convert.ToDecimal(this.printData.NetWeight));
                //            break;
                //        case "残保金":
                //            this.printData.TaxCanBaoPayMoney = (Convert.ToDecimal(taxRow[2].ToString())*
                //                                                Convert.ToDecimal(this.printData.NetWeight));
                //            break;
                //        case "排污费":
                //            this.printData.TaxSewagePayMoney = (Convert.ToDecimal(taxRow[2].ToString())*
                //                                                Convert.ToDecimal(this.printData.NetWeight));
                //            break;
                //        default:
                //            break;
                //    }
                //}
                //this.printData.PayMoney = Convert.ToDecimal(dtTable.Rows[0]["TaxAmount"].ToString());

                #endregion

                #region 销往目的地

                try
                {
                    string cityDataset = "select * from [TT_SalesCustomer] where SaleCode=@SaleCode";
                    SqlParameter sqlp_salecode = new SqlParameter("@SaleCode", dtTable.Rows[0]["CustomerName"].ToString());
                    DataTable saleCityName = SQLHelper.ExcuteDataTable(cityDataset, sqlp_salecode);
                    if (saleCityName.Rows.Count > 0)
                    {
                        this.printData.PayCity = saleCityName.Rows[0]["SaleCustomer"].ToString();
                    }
                    else
                    {
                        this.printData.PayCity = "";
                    }
                }
                catch (Exception e)
                {
                    LogHelper.WriteLog(LogHelper.GetCurSourceFileName() + "~" + LogHelper.GetLineNum() + "销往数据获取或加工异常!", e);
                }

                #endregion

                //this.printData.IsPrintTick = CarrierAdapter.Instance.Config.GetIsPrintTick();这个是从配置文件中获取数据,我没有找到
                InvoicePrint(this.printData);
            }
        }
Пример #7
0
        /// <summary>
        /// 二次打印
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button1_Click(object sender, EventArgs e)
        {
            if (!isnumeric(textBox1.Text))
            {
                MessageBox.Show("请输入正确的过磅编号","提醒");
                return;
            }

            #region 获取过磅数据

            int dataBaseTime = Convert.ToInt32(AppConfig.ReadValue("setting", "DataBaseTime"));
            string tableName = AppConfig.ReadValue("setting", "tableName");
            string[] tableNames = tableName.Split(',');
            string sql = null;
            DataTable dtTable = null;
            foreach (string item in tableNames)
            {
                sql =
                "select top 1 * FROM [IndustryPlatform].[dbo].[" + item + "] where [WeightCode]='" +
                textBox1.Text.ToString().Trim() + "' order by WeightTime desc";
                //                string weightTimeBegin = DateTime.Now.AddSeconds(dataBaseTime).ToString("yyyy-MM-dd HH:mm:ss");
                //                string weightTimeEnd = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                try
                {
                    dtTable = SQLHelper.ExcuteDataTable(sql);
                }
                catch (Exception ex)
                {
                    LogHelper.WriteLog(LogHelper.GetCurSourceFileName() + "~" + LogHelper.GetLineNum() + "获取过磅数据失败!", ex);
                }
                if (dtTable != null && dtTable.Rows.Count > 0)//找到数据,跳出循环
                {
                    break;
                }
            }

            #endregion

            if (dtTable != null && dtTable.Rows.Count > 0)
            {
                #region 加工过磅数据

                try
                {
                    printData = new PrintDataClass();
                    this.printData.RoomName = dtTable.Rows[0]["RoomName"].ToString();
                    this.printData.TradeID = dtTable.Rows[0]["WeightCode"].ToString();
                    this.printData.CoalKindName = dtTable.Rows[0]["CoalKindName"].ToString();
                    this.printData.CollName = dtTable.Rows[0]["CollName"].ToString();
                    this.printData.MarkedCardCode = dtTable.Rows[0]["MarkedCardCode"].ToString();
                    this.printData.NavicertCode = dtTable.Rows[0]["NavicertCode"].ToString();
                    this.printData.CarNo = dtTable.Rows[0]["CarNo"].ToString();
                    this.printData.CarOwnerName = dtTable.Rows[0]["CarOwnerName"].ToString();
                    this.printData.CarType = dtTable.Rows[0]["CarType"].ToString();
                    this.printData.CollManager = dtTable.Rows[0]["Operator"].ToString();
                    this.printData.LoadWeight = dtTable.Rows[0]["LoadWeight"].ToString();
                    this.printData.NetWeight = dtTable.Rows[0]["NetWeight"].ToString();
                    this.printData.EmptyWeight = dtTable.Rows[0]["EmptyWeight"].ToString();
                    this.printData.IsBeatUp = true;
                    this.printData.CoalSaleUnitPrice = Convert.ToDecimal(dtTable.Rows[0]["PayUnitPirce"].ToString());
                    this.printData.LoadWeightTime = dtTable.Rows[0]["WeightTime"].ToString();
                    this.printData.Operator = dtTable.Rows[0]["Operator"].ToString();
                }
                catch (Exception exception)
                {
                    LogHelper.WriteLog(LogHelper.GetCurSourceFileName() + "~" + LogHelper.GetLineNum() + "过磅数据加工异常!", exception);
                }

                #endregion

                #region 税费

                try
                {
                    SqlParameter sqlP_weightCode = new SqlParameter("@WeightCode", this.printData.TradeID);
                    DataTable dtTableMouney = SQLHelper.ExecSPDataSet("PT_LoadWeightTaxTwoPrint", sqlP_weightCode);

                    this.printData.TaxCounttryPayMoney = Convert.ToDecimal(dtTableMouney.Rows[0]["TaxCounttryPayMoney"]);
                    this.printData.TaxLocalPayMoney = Convert.ToDecimal(dtTableMouney.Rows[0]["TaxLocalPayMoney"]);
                    this.printData.TaxSewagePayMoney = Convert.ToDecimal(dtTableMouney.Rows[0]["TaxSewagePayMoney"]);
                    this.printData.TaxSoilWaterPayMoney = Convert.ToDecimal(dtTableMouney.Rows[0]["TaxSoilWaterPayMoney"]);
                    this.printData.TaxesPrice = Convert.ToDecimal(dtTableMouney.Rows[0]["CoalSaleUnitPrice"]);
                    this.printData.TaxFundPayMoney = Convert.ToDecimal(dtTableMouney.Rows[0]["TaxFundPayMoney"]);
                    this.printData.TaxCanBaoPayMoney = Convert.ToDecimal(dtTableMouney.Rows[0]["TaxCanBaoPayMoney"]);
                    this.printData.TaxYuLinPayMoney = Convert.ToDecimal(dtTableMouney.Rows[0]["TaxYuLinPayMoney"]);
                    this.printData.TaxYunShuPayMoney = Convert.ToDecimal(dtTableMouney.Rows[0]["TaxYunShuPayMoney"]);
                    this.printData.PayMoney = Convert.ToDecimal(dtTableMouney.Rows[0]["TaxPayMoney"]);
                    this.printData.PrintTimes = 1;
                }
                catch (Exception exception)
                {
                    LogHelper.WriteLog(LogHelper.GetCurSourceFileName() + "~" + LogHelper.GetLineNum() + "税费数据获取或加工异常!", exception);
                }

                //string sql_TaxItemDetail =
                //    "select * FROM [IndustryPlatform].[dbo].[VT_TaxItemDetail] where RoomCode=@RoomCode and CoalKindCode=@CoalKindCode";
                //SqlParameter[] sqlp_TaxItemDetail =
                //{
                //    new SqlParameter("@RoomCode", dtTable.Rows[0]["RoomCode"].ToString()),
                //    new SqlParameter("@CoalKindCode", dtTable.Rows[0]["CoalKindCode"].ToString()),
                //};
                //DataTable dtVT_TaxItemDetail = SQLHelper.ExcuteDataTable(sql_TaxItemDetail, sqlp_TaxItemDetail);
                //foreach (DataRow taxRow in dtVT_TaxItemDetail.Rows)
                //{
                //    switch (taxRow[1].ToString())
                //    {
                //        case "所得税":
                //            this.printData.TaxSuoDeShuiPayMoney = (Convert.ToDecimal(taxRow[2].ToString())*
                //                                                   Convert.ToDecimal(this.printData.NetWeight));
                //            break;
                //        case "资源税":
                //            this.printData.TaxLocalPayMoney = (Convert.ToDecimal(taxRow[2].ToString())*
                //                                               Convert.ToDecimal(this.printData.NetWeight));
                //            break;
                //        case "水土保持费":
                //            this.printData.TaxSoilWaterPayMoney = (Convert.ToDecimal(taxRow[2].ToString())*
                //                                                   Convert.ToDecimal(this.printData.NetWeight));
                //            break;
                //        case "育林基金":
                //            this.printData.TaxYuLinPayMoney = (Convert.ToDecimal(taxRow[2].ToString())*
                //                                               Convert.ToDecimal(this.printData.NetWeight));
                //            break;
                //        case "残保金":
                //            this.printData.TaxCanBaoPayMoney = (Convert.ToDecimal(taxRow[2].ToString())*
                //                                                Convert.ToDecimal(this.printData.NetWeight));
                //            break;
                //        case "排污费":
                //            this.printData.TaxSewagePayMoney = (Convert.ToDecimal(taxRow[2].ToString())*
                //                                                Convert.ToDecimal(this.printData.NetWeight));
                //            break;
                //        default:
                //            break;
                //    }
                //}
                //this.printData.PayMoney = Convert.ToDecimal(dtTable.Rows[0]["TaxAmount"].ToString());

                #endregion

                #region 销往目的地

                try
                {
                    string cityDataset = "select * from [TT_SalesCustomer] where SaleCode=@SaleCode";
                    SqlParameter sqlp_salecode = new SqlParameter("@SaleCode", dtTable.Rows[0]["CustomerName"].ToString());
                    DataTable saleCityName = SQLHelper.ExcuteDataTable(cityDataset, sqlp_salecode);
                    if (saleCityName.Rows.Count > 0)
                    {
                        this.printData.PayCity = saleCityName.Rows[0]["SaleCustomer"].ToString();
                    }
                    else
                    {
                        this.printData.PayCity = "";
                    }
                }
                catch (Exception exception)
                {
                    LogHelper.WriteLog(LogHelper.GetCurSourceFileName() + "~" + LogHelper.GetLineNum() + "销往数据获取或加工异常!", exception);
                }

                #endregion

                //this.printData.IsPrintTick = CarrierAdapter.Instance.Config.GetIsPrintTick();这个是从配置文件中获取数据,我没有找到
                InvoicePrint(this.printData);
                textBox1.Clear();
            }
        }
Пример #8
0
        /// <summary>
        /// 获取数据库中指定的时间间隔(配置文件)过磅数据
        /// </summary>
        private void GetDB()
        {
            #region 获取数据库中数据

            int    dataBaseTime = Convert.ToInt32(AppConfig.ReadValue("setting", "DataBaseTime"));
            string sql          =
                "select top 1 * FROM [IndustryPlatform].[dbo].[TT_LoadWeight] where RoomCode=@RoomCode and WeightTime between @WeightTimeBegin and @WeightTimeEnd order by WeightTime desc";
            string         weightTimeBegin = DateTime.Now.AddSeconds(dataBaseTime).ToString("yyyy-MM-dd HH:mm:ss");
            string         weightTimeEnd   = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
            SqlParameter[] sqlParameters   =
            {
                new SqlParameter("@WeightTimeBegin", weightTimeBegin),
                new SqlParameter("@WeightTimeEnd",   weightTimeEnd),
                new SqlParameter("@RoomCode",        AppConfig.ReadValue("setting", "RoomCode"))
            };
            DataTable dtTable = null;
            try
            {
                dtTable = SQLHelper.ExcuteDataTable(sql, sqlParameters);
            }
            catch (Exception e)
            {
                LogHelper.WriteLog(LogHelper.GetCurSourceFileName() + "~" + LogHelper.GetLineNum() + "获取过磅数据异常!", e);
            }

            #endregion

            if (dtTable != null && dtTable.Rows.Count > 0)
            {
                #region 过磅数据处理

                try
                {
                    printData = new PrintDataClass();
                    this.printData.RoomName          = dtTable.Rows[0]["RoomName"].ToString();
                    this.printData.TradeID           = dtTable.Rows[0]["WeightCode"].ToString();
                    this.printData.CoalKindName      = dtTable.Rows[0]["CoalKindName"].ToString();
                    this.printData.CollName          = dtTable.Rows[0]["CollName"].ToString();
                    this.printData.MarkedCardCode    = dtTable.Rows[0]["MarkedCardCode"].ToString();
                    this.printData.NavicertCode      = dtTable.Rows[0]["NavicertCode"].ToString();
                    this.printData.CarNo             = dtTable.Rows[0]["CarNo"].ToString();
                    this.printData.CarOwnerName      = dtTable.Rows[0]["CarOwnerName"].ToString();
                    this.printData.CarType           = dtTable.Rows[0]["CarType"].ToString();
                    this.printData.CollManager       = dtTable.Rows[0]["Operator"].ToString();
                    this.printData.LoadWeight        = dtTable.Rows[0]["LoadWeight"].ToString();
                    this.printData.NetWeight         = dtTable.Rows[0]["NetWeight"].ToString();
                    this.printData.EmptyWeight       = dtTable.Rows[0]["EmptyWeight"].ToString();
                    this.printData.IsBeatUp          = true;
                    this.printData.CoalSaleUnitPrice = Convert.ToDecimal(dtTable.Rows[0]["PayUnitPirce"].ToString());
                    this.printData.LoadWeightTime    = dtTable.Rows[0]["WeightTime"].ToString();
                    this.printData.Operator          = dtTable.Rows[0]["Operator"].ToString();
                }
                catch (Exception e)
                {
                    LogHelper.WriteLog(LogHelper.GetCurSourceFileName() + "~" + LogHelper.GetLineNum() + "过磅数加工据异常!", e);
                }

                #endregion

                #region 税费

                try
                {
                    SqlParameter sqlP_weightCode = new SqlParameter("@WeightCode", this.printData.TradeID);
                    DataTable    dtTableMouney   = SQLHelper.ExecSPDataSet("PT_LoadWeightTaxTwoPrint", sqlP_weightCode);

                    this.printData.TaxCounttryPayMoney  = Convert.ToDecimal(dtTableMouney.Rows[0]["TaxCounttryPayMoney"]);
                    this.printData.TaxLocalPayMoney     = Convert.ToDecimal(dtTableMouney.Rows[0]["TaxLocalPayMoney"]);
                    this.printData.TaxSewagePayMoney    = Convert.ToDecimal(dtTableMouney.Rows[0]["TaxSewagePayMoney"]);
                    this.printData.TaxSoilWaterPayMoney = Convert.ToDecimal(dtTableMouney.Rows[0]["TaxSoilWaterPayMoney"]);
                    this.printData.TaxesPrice           = Convert.ToDecimal(dtTableMouney.Rows[0]["CoalSaleUnitPrice"]);
                    this.printData.TaxFundPayMoney      = Convert.ToDecimal(dtTableMouney.Rows[0]["TaxFundPayMoney"]);
                    this.printData.TaxCanBaoPayMoney    = Convert.ToDecimal(dtTableMouney.Rows[0]["TaxCanBaoPayMoney"]);
                    this.printData.TaxYuLinPayMoney     = Convert.ToDecimal(dtTableMouney.Rows[0]["TaxYuLinPayMoney"]);
                    this.printData.TaxYunShuPayMoney    = Convert.ToDecimal(dtTableMouney.Rows[0]["TaxYunShuPayMoney"]);
                    this.printData.PayMoney             = Convert.ToDecimal(dtTableMouney.Rows[0]["TaxPayMoney"]);
                    this.printData.PrintTimes           = 1;
                }
                catch (Exception e)
                {
                    LogHelper.WriteLog(LogHelper.GetCurSourceFileName() + "~" + LogHelper.GetLineNum() + "税费获取或加工异常!", e);
                }


                //string sql_TaxItemDetail =
                //    "select * FROM [IndustryPlatform].[dbo].[VT_TaxItemDetail] where RoomCode=@RoomCode and CoalKindCode=@CoalKindCode";
                //SqlParameter[] sqlp_TaxItemDetail =
                //{
                //    new SqlParameter("@RoomCode", dtTable.Rows[0]["RoomCode"].ToString()),
                //    new SqlParameter("@CoalKindCode", dtTable.Rows[0]["CoalKindCode"].ToString()),
                //};
                //DataTable dtVT_TaxItemDetail = SQLHelper.ExcuteDataTable(sql_TaxItemDetail, sqlp_TaxItemDetail);
                //foreach (DataRow taxRow in dtVT_TaxItemDetail.Rows)
                //{
                //    switch (taxRow[1].ToString())
                //    {
                //        case "所得税":
                //            this.printData.TaxSuoDeShuiPayMoney = (Convert.ToDecimal(taxRow[2].ToString())*
                //                                                   Convert.ToDecimal(this.printData.NetWeight));
                //            break;
                //        case "资源税":
                //            this.printData.TaxLocalPayMoney = (Convert.ToDecimal(taxRow[2].ToString())*
                //                                               Convert.ToDecimal(this.printData.NetWeight));
                //            break;
                //        case "水土保持费":
                //            this.printData.TaxSoilWaterPayMoney = (Convert.ToDecimal(taxRow[2].ToString())*
                //                                                   Convert.ToDecimal(this.printData.NetWeight));
                //            break;
                //        case "育林基金":
                //            this.printData.TaxYuLinPayMoney = (Convert.ToDecimal(taxRow[2].ToString())*
                //                                               Convert.ToDecimal(this.printData.NetWeight));
                //            break;
                //        case "残保金":
                //            this.printData.TaxCanBaoPayMoney = (Convert.ToDecimal(taxRow[2].ToString())*
                //                                                Convert.ToDecimal(this.printData.NetWeight));
                //            break;
                //        case "排污费":
                //            this.printData.TaxSewagePayMoney = (Convert.ToDecimal(taxRow[2].ToString())*
                //                                                Convert.ToDecimal(this.printData.NetWeight));
                //            break;
                //        default:
                //            break;
                //    }
                //}
                //this.printData.PayMoney = Convert.ToDecimal(dtTable.Rows[0]["TaxAmount"].ToString());

                #endregion

                #region 销往目的地

                try
                {
                    string       cityDataset   = "select * from [TT_SalesCustomer] where SaleCode=@SaleCode";
                    SqlParameter sqlp_salecode = new SqlParameter("@SaleCode", dtTable.Rows[0]["CustomerName"].ToString());
                    DataTable    saleCityName  = SQLHelper.ExcuteDataTable(cityDataset, sqlp_salecode);
                    if (saleCityName.Rows.Count > 0)
                    {
                        this.printData.PayCity = saleCityName.Rows[0]["SaleCustomer"].ToString();
                    }
                    else
                    {
                        this.printData.PayCity = "";
                    }
                }
                catch (Exception e)
                {
                    LogHelper.WriteLog(LogHelper.GetCurSourceFileName() + "~" + LogHelper.GetLineNum() + "销往数据获取或加工异常!", e);
                }

                #endregion

                //this.printData.IsPrintTick = CarrierAdapter.Instance.Config.GetIsPrintTick();这个是从配置文件中获取数据,我没有找到
                InvoicePrint(this.printData);
            }
        }
Пример #9
0
        /// <summary>
        /// 二次打印
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button1_Click(object sender, EventArgs e)
        {
            if (!isnumeric(textBox1.Text))
            {
                MessageBox.Show("请输入正确的过磅编号", "提醒");
                return;
            }

            #region 获取过磅数据

            int       dataBaseTime = Convert.ToInt32(AppConfig.ReadValue("setting", "DataBaseTime"));
            string    tableName    = AppConfig.ReadValue("setting", "tableName");
            string[]  tableNames   = tableName.Split(',');
            string    sql          = null;
            DataTable dtTable      = null;
            foreach (string item in tableNames)
            {
                sql =
                    "select top 1 * FROM [IndustryPlatform].[dbo].[" + item + "] where [WeightCode]='" +
                    textBox1.Text.ToString().Trim() + "' order by WeightTime desc";
                //                string weightTimeBegin = DateTime.Now.AddSeconds(dataBaseTime).ToString("yyyy-MM-dd HH:mm:ss");
                //                string weightTimeEnd = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                try
                {
                    dtTable = SQLHelper.ExcuteDataTable(sql);
                }
                catch (Exception ex)
                {
                    LogHelper.WriteLog(LogHelper.GetCurSourceFileName() + "~" + LogHelper.GetLineNum() + "获取过磅数据失败!", ex);
                }
                if (dtTable != null && dtTable.Rows.Count > 0)//找到数据,跳出循环
                {
                    break;
                }
            }

            #endregion



            if (dtTable != null && dtTable.Rows.Count > 0)
            {
                #region 加工过磅数据

                try
                {
                    printData = new PrintDataClass();
                    this.printData.RoomName          = dtTable.Rows[0]["RoomName"].ToString();
                    this.printData.TradeID           = dtTable.Rows[0]["WeightCode"].ToString();
                    this.printData.CoalKindName      = dtTable.Rows[0]["CoalKindName"].ToString();
                    this.printData.CollName          = dtTable.Rows[0]["CollName"].ToString();
                    this.printData.MarkedCardCode    = dtTable.Rows[0]["MarkedCardCode"].ToString();
                    this.printData.NavicertCode      = dtTable.Rows[0]["NavicertCode"].ToString();
                    this.printData.CarNo             = dtTable.Rows[0]["CarNo"].ToString();
                    this.printData.CarOwnerName      = dtTable.Rows[0]["CarOwnerName"].ToString();
                    this.printData.CarType           = dtTable.Rows[0]["CarType"].ToString();
                    this.printData.CollManager       = dtTable.Rows[0]["Operator"].ToString();
                    this.printData.LoadWeight        = dtTable.Rows[0]["LoadWeight"].ToString();
                    this.printData.NetWeight         = dtTable.Rows[0]["NetWeight"].ToString();
                    this.printData.EmptyWeight       = dtTable.Rows[0]["EmptyWeight"].ToString();
                    this.printData.IsBeatUp          = true;
                    this.printData.CoalSaleUnitPrice = Convert.ToDecimal(dtTable.Rows[0]["PayUnitPirce"].ToString());
                    this.printData.LoadWeightTime    = dtTable.Rows[0]["WeightTime"].ToString();
                    this.printData.Operator          = dtTable.Rows[0]["Operator"].ToString();
                }
                catch (Exception exception)
                {
                    LogHelper.WriteLog(LogHelper.GetCurSourceFileName() + "~" + LogHelper.GetLineNum() + "过磅数据加工异常!", exception);
                }

                #endregion

                #region 税费

                try
                {
                    SqlParameter sqlP_weightCode = new SqlParameter("@WeightCode", this.printData.TradeID);
                    DataTable    dtTableMouney   = SQLHelper.ExecSPDataSet("PT_LoadWeightTaxTwoPrint", sqlP_weightCode);

                    this.printData.TaxCounttryPayMoney  = Convert.ToDecimal(dtTableMouney.Rows[0]["TaxCounttryPayMoney"]);
                    this.printData.TaxLocalPayMoney     = Convert.ToDecimal(dtTableMouney.Rows[0]["TaxLocalPayMoney"]);
                    this.printData.TaxSewagePayMoney    = Convert.ToDecimal(dtTableMouney.Rows[0]["TaxSewagePayMoney"]);
                    this.printData.TaxSoilWaterPayMoney = Convert.ToDecimal(dtTableMouney.Rows[0]["TaxSoilWaterPayMoney"]);
                    this.printData.TaxesPrice           = Convert.ToDecimal(dtTableMouney.Rows[0]["CoalSaleUnitPrice"]);
                    this.printData.TaxFundPayMoney      = Convert.ToDecimal(dtTableMouney.Rows[0]["TaxFundPayMoney"]);
                    this.printData.TaxCanBaoPayMoney    = Convert.ToDecimal(dtTableMouney.Rows[0]["TaxCanBaoPayMoney"]);
                    this.printData.TaxYuLinPayMoney     = Convert.ToDecimal(dtTableMouney.Rows[0]["TaxYuLinPayMoney"]);
                    this.printData.TaxYunShuPayMoney    = Convert.ToDecimal(dtTableMouney.Rows[0]["TaxYunShuPayMoney"]);
                    this.printData.PayMoney             = Convert.ToDecimal(dtTableMouney.Rows[0]["TaxPayMoney"]);
                    this.printData.PrintTimes           = 1;
                }
                catch (Exception exception)
                {
                    LogHelper.WriteLog(LogHelper.GetCurSourceFileName() + "~" + LogHelper.GetLineNum() + "税费数据获取或加工异常!", exception);
                }


                //string sql_TaxItemDetail =
                //    "select * FROM [IndustryPlatform].[dbo].[VT_TaxItemDetail] where RoomCode=@RoomCode and CoalKindCode=@CoalKindCode";
                //SqlParameter[] sqlp_TaxItemDetail =
                //{
                //    new SqlParameter("@RoomCode", dtTable.Rows[0]["RoomCode"].ToString()),
                //    new SqlParameter("@CoalKindCode", dtTable.Rows[0]["CoalKindCode"].ToString()),
                //};
                //DataTable dtVT_TaxItemDetail = SQLHelper.ExcuteDataTable(sql_TaxItemDetail, sqlp_TaxItemDetail);
                //foreach (DataRow taxRow in dtVT_TaxItemDetail.Rows)
                //{
                //    switch (taxRow[1].ToString())
                //    {
                //        case "所得税":
                //            this.printData.TaxSuoDeShuiPayMoney = (Convert.ToDecimal(taxRow[2].ToString())*
                //                                                   Convert.ToDecimal(this.printData.NetWeight));
                //            break;
                //        case "资源税":
                //            this.printData.TaxLocalPayMoney = (Convert.ToDecimal(taxRow[2].ToString())*
                //                                               Convert.ToDecimal(this.printData.NetWeight));
                //            break;
                //        case "水土保持费":
                //            this.printData.TaxSoilWaterPayMoney = (Convert.ToDecimal(taxRow[2].ToString())*
                //                                                   Convert.ToDecimal(this.printData.NetWeight));
                //            break;
                //        case "育林基金":
                //            this.printData.TaxYuLinPayMoney = (Convert.ToDecimal(taxRow[2].ToString())*
                //                                               Convert.ToDecimal(this.printData.NetWeight));
                //            break;
                //        case "残保金":
                //            this.printData.TaxCanBaoPayMoney = (Convert.ToDecimal(taxRow[2].ToString())*
                //                                                Convert.ToDecimal(this.printData.NetWeight));
                //            break;
                //        case "排污费":
                //            this.printData.TaxSewagePayMoney = (Convert.ToDecimal(taxRow[2].ToString())*
                //                                                Convert.ToDecimal(this.printData.NetWeight));
                //            break;
                //        default:
                //            break;
                //    }
                //}
                //this.printData.PayMoney = Convert.ToDecimal(dtTable.Rows[0]["TaxAmount"].ToString());

                #endregion

                #region 销往目的地

                try
                {
                    string       cityDataset   = "select * from [TT_SalesCustomer] where SaleCode=@SaleCode";
                    SqlParameter sqlp_salecode = new SqlParameter("@SaleCode", dtTable.Rows[0]["CustomerName"].ToString());
                    DataTable    saleCityName  = SQLHelper.ExcuteDataTable(cityDataset, sqlp_salecode);
                    if (saleCityName.Rows.Count > 0)
                    {
                        this.printData.PayCity = saleCityName.Rows[0]["SaleCustomer"].ToString();
                    }
                    else
                    {
                        this.printData.PayCity = "";
                    }
                }
                catch (Exception exception)
                {
                    LogHelper.WriteLog(LogHelper.GetCurSourceFileName() + "~" + LogHelper.GetLineNum() + "销往数据获取或加工异常!", exception);
                }

                #endregion

                //this.printData.IsPrintTick = CarrierAdapter.Instance.Config.GetIsPrintTick();这个是从配置文件中获取数据,我没有找到
                InvoicePrint(this.printData);
                textBox1.Clear();
            }
        }
Пример #10
0
        /// <summary>
        /// 根据文本中的过磅编号获取过磅数据并打印
        /// </summary>
        private void GetDBNew()
        {
            #region 根据过磅编号获取数据库中数据

            string NO = GetTextDate();
            if (string.IsNullOrEmpty(NO))
            {
                LogHelper.WriteLog(LogHelper.GetCurSourceFileName() + "~" + LogHelper.GetLineNum() + "过磅编号为空");
                return;
            }
            int       dataBaseTime = Convert.ToInt32(AppConfig.ReadValue("setting", "DataBaseTime"));
            string    tableName    = AppConfig.ReadValue("setting", "tableName");
            string[]  tableNames   = tableName.Split(',');
            string    sql          = null;
            DataTable dtTable      = null;
            foreach (string item in tableNames)
            {
                sql =
                    "select top 1 * FROM [IndustryPlatform].[dbo].[" + item + "] where [WeightCode]='" + NO +
                    "' order by WeightTime desc";
                //                string weightTimeBegin = DateTime.Now.AddSeconds(dataBaseTime).ToString("yyyy-MM-dd HH:mm:ss");
                //                string weightTimeEnd = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");

                try
                {
                    dtTable = SQLHelper.ExcuteDataTable(sql);
                }
                catch (Exception e)
                {
                    LogHelper.WriteLog(LogHelper.GetCurSourceFileName() + "~" + LogHelper.GetLineNum() + "获取过磅数据失败!", e);
                }
                if (dtTable != null && dtTable.Rows.Count > 0)//找到数据,跳出循环
                {
                    break;
                }
            }

            #endregion

            if (dtTable != null && dtTable.Rows.Count > 0)
            {
                #region 处理过磅数据

                try
                {
                    printData = new PrintDataClass();
                    this.printData.RoomName       = dtTable.Rows[0]["RoomName"].ToString();
                    this.printData.TradeID        = dtTable.Rows[0]["WeightCode"].ToString();
                    this.printData.CoalKindName   = dtTable.Rows[0]["CoalKindName"].ToString();
                    this.printData.CollName       = dtTable.Rows[0]["CollName"].ToString();
                    this.printData.MarkedCardCode = dtTable.Rows[0]["MarkedCardCode"].ToString();
                    this.printData.NavicertCode   = dtTable.Rows[0]["NavicertCode"].ToString();
                    this.printData.CarNo          = dtTable.Rows[0]["CarNo"].ToString();
                    this.printData.CarOwnerName   = dtTable.Rows[0]["CarOwnerName"].ToString();
                    this.printData.CarType        = dtTable.Rows[0]["CarType"].ToString();
                    this.printData.CollManager    = dtTable.Rows[0]["Operator"].ToString();
                    this.printData.LoadWeight     = dtTable.Rows[0]["LoadWeight"].ToString();
                    this.printData.NetWeight      = dtTable.Rows[0]["NetWeight"].ToString();
                    this.printData.EmptyWeight    = dtTable.Rows[0]["EmptyWeight"].ToString();
                    this.printData.IsBeatUp       = true;
                    try
                    {
                        this.printData.CoalSaleUnitPrice = Convert.ToDecimal(dtTable.Rows[0]["PayUnitPirce"].ToString());
                    }
                    catch
                    {
                        this.printData.CoalSaleUnitPrice = 0;
                    }
                    this.printData.LoadWeightTime = dtTable.Rows[0]["WeightTime"].ToString();
                    this.printData.Operator       = dtTable.Rows[0]["Operator"].ToString();
                }
                catch (Exception e)
                {
                    LogHelper.WriteLog(LogHelper.GetCurSourceFileName() + "~" + LogHelper.GetLineNum() + "处理过磅数据异常!", e);
                }

                #endregion

                #region 税费

                try
                {
                    SqlParameter sqlP_weightCode = new SqlParameter("@WeightCode", this.printData.TradeID);
                    DataTable    dtTableMouney   = SQLHelper.ExecSPDataSet("PT_LoadWeightTaxTwoPrint", sqlP_weightCode);

                    this.printData.TaxCounttryPayMoney  = Convert.ToDecimal(dtTableMouney.Rows[0]["TaxCounttryPayMoney"]);
                    this.printData.TaxLocalPayMoney     = Convert.ToDecimal(dtTableMouney.Rows[0]["TaxLocalPayMoney"]);
                    this.printData.TaxSewagePayMoney    = Convert.ToDecimal(dtTableMouney.Rows[0]["TaxSewagePayMoney"]);
                    this.printData.TaxSoilWaterPayMoney =
                        Convert.ToDecimal(dtTableMouney.Rows[0]["TaxSoilWaterPayMoney"]);
                    this.printData.TaxesPrice        = Convert.ToDecimal(dtTableMouney.Rows[0]["CoalSaleUnitPrice"]);
                    this.printData.TaxFundPayMoney   = Convert.ToDecimal(dtTableMouney.Rows[0]["TaxFundPayMoney"]);
                    this.printData.TaxCanBaoPayMoney = Convert.ToDecimal(dtTableMouney.Rows[0]["TaxCanBaoPayMoney"]);
                    this.printData.TaxYuLinPayMoney  = Convert.ToDecimal(dtTableMouney.Rows[0]["TaxYuLinPayMoney"]);
                    this.printData.TaxYunShuPayMoney = Convert.ToDecimal(dtTableMouney.Rows[0]["TaxYunShuPayMoney"]);
                    this.printData.PayMoney          = Convert.ToDecimal(dtTableMouney.Rows[0]["TaxPayMoney"]);
                    this.printData.PrintTimes        = 1;
                }
                catch (Exception e)
                {
                    LogHelper.WriteLog(LogHelper.GetCurSourceFileName() + "~" + LogHelper.GetLineNum() + "获取税费并加工异常!", e);
                }

                #endregion

                #region 销往目的地

                try
                {
                    string       cityDataset   = "select * from [TT_SalesCustomer] where SaleCode=@SaleCode";
                    SqlParameter sqlp_salecode = new SqlParameter("@SaleCode",
                                                                  dtTable.Rows[0]["CustomerName"].ToString());
                    DataTable saleCityName = SQLHelper.ExcuteDataTable(cityDataset, sqlp_salecode);
                    if (saleCityName.Rows.Count > 0)
                    {
                        this.printData.PayCity = saleCityName.Rows[0]["SaleCustomer"].ToString();
                    }
                    else
                    {
                        this.printData.PayCity = "";
                    }
                }
                catch (Exception e)
                {
                    LogHelper.WriteLog(
                        LogHelper.GetCurSourceFileName() + "~" + LogHelper.GetLineNum() + "获取销往目的地数据异常!", e);
                }

                #endregion

                InvoicePrint(this.printData); //打印
                try
                {
                    if (File.Exists(filePath)) //打印完成后删除文件
                    {
                        FileInfo fi = new FileInfo(filePath);
                        if (fi.Attributes.ToString().IndexOf("ReadOnly") != -1)
                        {
                            fi.Attributes = FileAttributes.Normal;
                        }
                        File.Delete(filePath);
                    }
                }
                catch (Exception e)
                {
                    LogHelper.WriteLog(LogHelper.GetCurSourceFileName() + "~" + LogHelper.GetLineNum() + "文本删除失败!", e);
                }
            }
        }
 public override void LoadWeightPaintDocument(Graphics g, PrintDataClass pdc, string PrintTitle)
 {
     FontStyle bold = FontStyle.Bold;
     Font font = new Font("黑体", 22f, bold);
     FontStyle regular = FontStyle.Regular;
     Font font2 = new Font("宋体", 11f, regular, GraphicsUnit.Point);
     FontStyle style = FontStyle.Regular;
     Font font3 = new Font("宋体", 14f, style, GraphicsUnit.Point);
     FontStyle style4 = FontStyle.Bold;
     Font font4 = new Font("宋体", 11f, style4, GraphicsUnit.Point);
     FontStyle italic = FontStyle.Italic;
     italic |= FontStyle.Bold;
     Font font5 = new Font("宋体", 10f, italic, GraphicsUnit.Point);
     FontStyle style6 = FontStyle.Regular;
     Font font6 = new Font("宋体", 11f, style6, GraphicsUnit.Point);
     FontStyle style7 = FontStyle.Regular;
     Font font7 = new Font("宋体", 10f, style7, GraphicsUnit.Point);
     StringFormat format = new StringFormat
     {
         LineAlignment = StringAlignment.Center
     };
     g.DrawString(pdc.CollName, font2, Brushes.Black, (PointF)base.GetPoint(base.m_Rect_x + 3.2M, base.m_Rect_y+0.1m));
     g.DrawString(pdc.TradeID, font4, Brushes.Black, (PointF)base.GetPoint(base.m_Rect_x + 11.8M, base.m_Rect_y++));
        // g.DrawString(pdc.CollName, font2, Brushes.Black, (PointF)base.GetPoint(base.m_Rect_x + 3.2M, decimal.op_Decrement(base.m_Rect_y)));
        // g.DrawString(pdc.TradeID, font4, Brushes.Black, (PointF)base.GetPoint(base.m_Rect_x + 11.8M, decimal.op_Decrement(base.m_Rect_y)));
     decimal num = 0.0M;
     g.DrawString(pdc.CollName, font2, Brushes.Black, (PointF)base.GetPoint((base.m_Rect_x + base.m_decX) + base.m_First_Column_W, (base.m_Rect_y + num) + base.m_decY));
     g.DrawString(pdc.CarNo, font2, Brushes.Black, (PointF)base.GetPoint((((base.m_Rect_x + base.m_First_Column_W) + base.m_Second_Column_W) + base.m_Third_Column_W) + base.m_decX, (base.m_Rect_y + num) + base.m_decY));
     num = base.m_LineHeight * 1M;
     g.DrawString(pdc.NavicertCode, font2, Brushes.Black, (PointF)base.GetPoint((base.m_Rect_x + base.m_decX) + base.m_First_Column_W, (base.m_Rect_y + num) + base.m_decY));
     g.DrawString(pdc.LoadWeight.ToString(), font2, Brushes.Black, (PointF)base.GetPoint((((base.m_Rect_x + base.m_First_Column_W) + base.m_Second_Column_W) + base.m_Third_Column_W) + base.m_decX, (base.m_Rect_y + num) + base.m_decY));
     num = base.m_LineHeight * 2M;
     g.DrawString(pdc.MarkedCardCode, font2, Brushes.Black, (PointF)base.GetPoint((base.m_Rect_x + base.m_decX) + base.m_First_Column_W, (base.m_Rect_y + num) + base.m_decY));
     g.DrawString(pdc.EmptyWeight.ToString(), font2, Brushes.Black, (PointF)base.GetPoint((((base.m_Rect_x + base.m_First_Column_W) + base.m_Second_Column_W) + base.m_Third_Column_W) + base.m_decX, (base.m_Rect_y + num) + base.m_decY));
     num = base.m_LineHeight * 3M;
     g.DrawString(pdc.CoalKindName, font2, Brushes.Black, (PointF)base.GetPoint((base.m_Rect_x + base.m_decX) + base.m_First_Column_W, (base.m_Rect_y + num) + base.m_decY));
     g.DrawString(pdc.NetWeight.ToString(), font2, Brushes.Black, (PointF)base.GetPoint((((base.m_Rect_x + base.m_First_Column_W) + base.m_Second_Column_W) + base.m_Third_Column_W) + base.m_decX, (base.m_Rect_y + num) + base.m_decY));
     num = base.m_LineHeight * 4M;
     g.DrawString("残保金"+pdc.TaxCanBaoPayMoney.ToString("0.00"), font2, Brushes.Black, (PointF)base.GetPoint((base.m_Rect_x + base.m_decX) + base.m_First_Column_W, (base.m_Rect_y + num) + base.m_decY));
     g.DrawString("所得税" + pdc.TaxSuoDeShuiPayMoney.ToString("0.00"), font2, Brushes.Black, (PointF)base.GetPoint((((base.m_Rect_x + base.m_First_Column_W) + base.m_Second_Column_W) + base.m_Third_Column_W) + base.m_decX, (base.m_Rect_y + num) + base.m_decY));
     num = base.m_LineHeight * 5M;
     g.DrawString("排污费" + pdc.TaxSewagePayMoney.ToString("0.00"), font2, Brushes.Black, (PointF)base.GetPoint((base.m_Rect_x + base.m_decX) + base.m_First_Column_W, (base.m_Rect_y + num) + base.m_decY));
     g.DrawString("资源税" + pdc.TaxLocalPayMoney.ToString("0.00"), font2, Brushes.Black, (PointF)base.GetPoint((((base.m_Rect_x + base.m_First_Column_W) + base.m_Second_Column_W) + base.m_Third_Column_W) + base.m_decX, (base.m_Rect_y + num) + base.m_decY));
     num = base.m_LineHeight * 6M;
     g.DrawString("育林基金" + pdc.TaxYuLinPayMoney.ToString("0.00"), font2, Brushes.Black, (PointF)base.GetPoint((base.m_Rect_x + base.m_decX) + base.m_First_Column_W, (base.m_Rect_y + num) + base.m_decY));
     g.DrawString("水土保持" + pdc.TaxSoilWaterPayMoney.ToString("0.00"), font2, Brushes.Black, (PointF)base.GetPoint((((base.m_Rect_x + base.m_First_Column_W) + base.m_Second_Column_W) + base.m_Third_Column_W) + base.m_decX, (base.m_Rect_y + num) + base.m_decY));
     num = base.m_LineHeight * 7M;
     g.DrawString("销售单价" + pdc.CoalSaleUnitPrice.ToString("0.00"), font2, Brushes.Black, (PointF)base.GetPoint((base.m_Rect_x + base.m_decX) + base.m_First_Column_W, (base.m_Rect_y + num) + base.m_decY));
     g.DrawString("运输税" + pdc.TaxYunShuPayMoney.ToString("0.00"), font2, Brushes.Black, (PointF)base.GetPoint((((base.m_Rect_x + base.m_First_Column_W) + base.m_Second_Column_W) + base.m_Third_Column_W) + base.m_decX, (base.m_Rect_y + num) + base.m_decY));
     num = base.m_LineHeight * 8M;
     g.DrawString(pdc.PayCity, font2, Brushes.Black, (PointF)base.GetPoint((base.m_Rect_x + base.m_decX) + base.m_First_Column_W, (base.m_Rect_y + num) + base.m_decY));
     g.DrawString("销售收入" + (pdc.CoalSaleUnitPrice * Convert.ToDecimal(pdc.NetWeight.ToString())).ToString("0.00"), font2, Brushes.Black, (PointF)base.GetPoint((((base.m_Rect_x + base.m_First_Column_W) + base.m_Second_Column_W) + base.m_Third_Column_W) + base.m_decX, (base.m_Rect_y + num) + base.m_decY));
     num = base.m_LineHeight * 9M;
     string s = ConvertData.ConvertSum(pdc.PayMoney.ToString("0.00")) + " (¥" + pdc.PayMoney.ToString("0.00") + ")";
     g.DrawString(s, font2, Brushes.Black, (PointF)base.GetPoint((base.m_Rect_x + base.m_First_Column_W) + 0.1M, (base.m_Rect_y + num) + 0.7M));
     string str2 = "";
     if (pdc.PrintTimes > 1)
     {
         str2 = "此单据为发票补打票据";
     }
     g.DrawString(str2, font7, Brushes.Black, (PointF)base.GetPoint(base.m_Rect_x + 3.8M, (base.m_Rect_y + base.rect_H) + 0.2M));
     g.DrawString(pdc.LoadWeightTime, font7, Brushes.Black, (PointF)base.GetPoint(base.m_Rect_x + 12.3M, (base.m_Rect_y + base.rect_H) + 0.2M));
 }
 public virtual void LoadWeightPaintDocument(Graphics g, PrintDataClass pdc, string PrintTitle)
 {
 }