Exemplo n.º 1
0
 private void 打印ToolStripMenuItem_Click(object sender, EventArgs e)
 {
     try
     {
         if (t_dgv_Data.CurrentRow == null)
         {
             this.Warning("请先选择要打印的快递单!");
             return;
         }
         if (t_dgv_Data.SelectedRows == null)
         {
             return;
         }
         //获得选中集合
         DataGridViewSelectedRowCollection myRows = t_dgv_Data.SelectedRows;
         if (myRows == null || myRows.Count <= 0)
         {
             return;
         }
         //打印集合
         List <MExpress> mExpressList = new List <MExpress>();
         foreach (DataGridViewRow item in myRows)
         {
             MExpress myExpress = item.DataBoundItem as MExpress;
             mExpressList.Add(myExpress);
         }
         //批量打印
         m_CommonBLL.MorePrint(mExpressList);
         this.Info(string.Format("打印成功!共{0}单!", mExpressList.Count));
         //刷新
         t_txt_Search_Click(null, null);
     }
     catch (Exception ex)
     {
         this.Warning(ex.Message);
     }
 }
Exemplo n.º 2
0
        /// <summary>
        /// 表示获取打印数据源
        /// </summary>
        /// <param name="templateName"></param>
        public List <MExpressItemConfig> GetPrintResource(string templateName, MExpress mExpress)
        {
            List <MExpressItemConfig> myList = GetPrintItemConfig(templateName);
            var props = typeof(MExpress).GetProperties();//表示实体对象

            foreach (MExpressItemConfig ItemConfigModel in myList)
            {
                //获取名称
                string name = ItemConfigModel.ItemlCode;
                if (!string.IsNullOrEmpty(ItemConfigModel.TemplateName))
                {
                    name = name.Replace("_", "");
                }
                foreach (var prop in props)
                {
                    if (name == prop.Name)
                    {
                        ItemConfigModel.ItemlName = prop.GetValue(mExpress).ToString();
                        break;
                    }
                }
            }
            return(myList);
        }
Exemplo n.º 3
0
        /// <summary>
        /// 向数据库中添加一条记录
        /// </summary>
        /// <param name="model">要添加的实体</param>
        /// <returns>插入数据的ID</returns>
        public int Insert(MExpress model)
        {
            #region SQL语句
            const string sql = @"
INSERT INTO [T_Express] (
	[UUID]
	,[Sender_Tel]
	,[Sender_Province]
	,[Sender_City]
	,[Receive_Province]
	,[Receive_City]
	,[Receive_Name]
	,[Receive_ZipCode]
	,[Receive_Address]
	,[Receive_Company_Name]
	,[Receive_Phone]
	,[Express_No]
	,[Receive_Tel]
	,[Goods_Pic]
	,[Goods_Name]
	,[Goods_Size]
	,[Sum]
	,[Is_Stock]
	,[Is_Print]
	,[Status]
	,[Expree_Type]
	,[Expree_Date]
	,[Sender_Name]
	,[Sender_ZipCode]
	,[Sender_Address]
	,[Sender_Company_Name]
	,[Sender_Phone]
)
VALUES (
	@UUID
	,@Sender_Tel
	,@Sender_Province
	,@Sender_City
	,@Receive_Province
	,@Receive_City
	,@Receive_Name
	,@Receive_ZipCode
	,@Receive_Address
	,@Receive_Company_Name
	,@Receive_Phone
	,@Express_No
	,@Receive_Tel
	,@Goods_Pic
	,@Goods_Name
	,@Goods_Size
	,@Sum
	,@Is_Stock
	,@Is_Print
	,@Status
	,@Expree_Type
	,@Expree_Date
	,@Sender_Name
	,@Sender_ZipCode
	,@Sender_Address
	,@Sender_Company_Name
	,@Sender_Phone
);";
            #endregion
            var res = SqlHelper.ExecuteNonQuery(CommandType.Text, sql,
                                                new SQLiteParameter("@UUID", SqlHelper.ToNullDBValue(model.UUID)),
                                                new SQLiteParameter("@Sender_Tel", SqlHelper.ToNullDBValue(model.SenderTel)),
                                                new SQLiteParameter("@Sender_Province", SqlHelper.ToNullDBValue(model.SenderProvince)),
                                                new SQLiteParameter("@Sender_City", SqlHelper.ToNullDBValue(model.SenderCity)),
                                                new SQLiteParameter("@Receive_Province", SqlHelper.ToNullDBValue(model.ReceiveProvince)),
                                                new SQLiteParameter("@Receive_City", SqlHelper.ToNullDBValue(model.ReceiveCity)),
                                                new SQLiteParameter("@Receive_Name", SqlHelper.ToNullDBValue(model.ReceiveName)),
                                                new SQLiteParameter("@Receive_ZipCode", SqlHelper.ToNullDBValue(model.ReceiveZipCode)),
                                                new SQLiteParameter("@Receive_Address", SqlHelper.ToNullDBValue(model.ReceiveAddress)),
                                                new SQLiteParameter("@Receive_Company_Name", SqlHelper.ToNullDBValue(model.ReceiveCompanyName)),
                                                new SQLiteParameter("@Receive_Phone", SqlHelper.ToNullDBValue(model.ReceivePhone)),
                                                new SQLiteParameter("@Express_No", SqlHelper.ToNullDBValue(model.ExpressNo)),
                                                new SQLiteParameter("@Receive_Tel", SqlHelper.ToNullDBValue(model.ReceiveTel)),
                                                new SQLiteParameter("@Goods_Pic", SqlHelper.ToNullDBValue(model.GoodsPic)),
                                                new SQLiteParameter("@Goods_Name", SqlHelper.ToNullDBValue(model.GoodsName)),
                                                new SQLiteParameter("@Goods_Size", SqlHelper.ToNullDBValue(model.GoodsSize)),
                                                new SQLiteParameter("@Sum", SqlHelper.ToNullDBValue(model.Sum)),
                                                new SQLiteParameter("@Is_Stock", SqlHelper.ToNullDBValue(model.IsStock)),
                                                new SQLiteParameter("@Is_Print", SqlHelper.ToNullDBValue(model.IsPrint)),
                                                new SQLiteParameter("@Status", SqlHelper.ToNullDBValue(model.Status)),
                                                new SQLiteParameter("@Expree_Type", SqlHelper.ToNullDBValue(model.ExpreeType)),
                                                new SQLiteParameter("@Expree_Date", SqlHelper.ToNullDBValue(model.ExpreeDate)),
                                                new SQLiteParameter("@Sender_Name", SqlHelper.ToNullDBValue(model.SenderName)),
                                                new SQLiteParameter("@Sender_ZipCode", SqlHelper.ToNullDBValue(model.SenderZipCode)),
                                                new SQLiteParameter("@Sender_Address", SqlHelper.ToNullDBValue(model.SenderAddress)),
                                                new SQLiteParameter("@Sender_Company_Name", SqlHelper.ToNullDBValue(model.SenderCompanyName)),
                                                new SQLiteParameter("@Sender_Phone", SqlHelper.ToNullDBValue(model.SenderPhone))
                                                );
            return(Convert.ToInt32(res));
        }
Exemplo n.º 4
0
        /// <summary>
        /// 根据主键ID更新一条记录
        /// </summary>
        /// <param name="model">更新后的实体</param>
        /// <returns>执行结果受影响行数</returns>
        public int Update(MExpress model)
        {
            #region SQL语句
            const string sql = @"
UPDATE [T_Express]
SET 
	 [UUID] = @UUID
	,[Sender_Tel] = @Sender_Tel
	,[Sender_Province] = @Sender_Province
	,[Sender_City] = @Sender_City
	,[Receive_Province] = @Receive_Province
	,[Receive_City] = @Receive_City
	,[Receive_Name] = @Receive_Name
	,[Receive_ZipCode] = @Receive_ZipCode
	,[Receive_Address] = @Receive_Address
	,[Receive_Company_Name] = @Receive_Company_Name
	,[Receive_Phone] = @Receive_Phone
	,[Express_No] = @Express_No
	,[Receive_Tel] = @Receive_Tel
	,[Goods_Pic] = @Goods_Pic
	,[Goods_Name] = @Goods_Name
	,[Goods_Size] = @Goods_Size
	,[Sum] = @Sum
	,[Is_Stock] = @Is_Stock
	,[Is_Print] = @Is_Print
	,[Status] = @Status
	,[Expree_Type] = @Expree_Type
	,[Expree_Date] = @Expree_Date
	,[Sender_Name] = @Sender_Name
	,[Sender_ZipCode] = @Sender_ZipCode
	,[Sender_Address] = @Sender_Address
	,[Sender_Company_Name] = @Sender_Company_Name
	,[Sender_Phone] = @Sender_Phone
WHERE [UUID] = @UUID";
            #endregion
            return(SqlHelper.ExecuteNonQuery(myCommandType, sql,
                                             new SQLiteParameter("@UUID", SqlHelper.ToNullDBValue(model.UUID)),
                                             new SQLiteParameter("@Sender_Tel", SqlHelper.ToNullDBValue(model.SenderTel)),
                                             new SQLiteParameter("@Sender_Province", SqlHelper.ToNullDBValue(model.SenderProvince)),
                                             new SQLiteParameter("@Sender_City", SqlHelper.ToNullDBValue(model.SenderCity)),
                                             new SQLiteParameter("@Receive_Province", SqlHelper.ToNullDBValue(model.ReceiveProvince)),
                                             new SQLiteParameter("@Receive_City", SqlHelper.ToNullDBValue(model.ReceiveCity)),
                                             new SQLiteParameter("@Receive_Name", SqlHelper.ToNullDBValue(model.ReceiveName)),
                                             new SQLiteParameter("@Receive_ZipCode", SqlHelper.ToNullDBValue(model.ReceiveZipCode)),
                                             new SQLiteParameter("@Receive_Address", SqlHelper.ToNullDBValue(model.ReceiveAddress)),
                                             new SQLiteParameter("@Receive_Company_Name", SqlHelper.ToNullDBValue(model.ReceiveCompanyName)),
                                             new SQLiteParameter("@Receive_Phone", SqlHelper.ToNullDBValue(model.ReceivePhone)),
                                             new SQLiteParameter("@Express_No", SqlHelper.ToNullDBValue(model.ExpressNo)),
                                             new SQLiteParameter("@Receive_Tel", SqlHelper.ToNullDBValue(model.ReceiveTel)),
                                             new SQLiteParameter("@Goods_Pic", SqlHelper.ToNullDBValue(model.GoodsPic)),
                                             new SQLiteParameter("@Goods_Name", SqlHelper.ToNullDBValue(model.GoodsName)),
                                             new SQLiteParameter("@Goods_Size", SqlHelper.ToNullDBValue(model.GoodsSize)),
                                             new SQLiteParameter("@Sum", SqlHelper.ToNullDBValue(model.Sum)),
                                             new SQLiteParameter("@Is_Stock", SqlHelper.ToNullDBValue(model.IsStock)),
                                             new SQLiteParameter("@Is_Print", SqlHelper.ToNullDBValue(model.IsPrint)),
                                             new SQLiteParameter("@Status", SqlHelper.ToNullDBValue(model.Status)),
                                             new SQLiteParameter("@Expree_Type", SqlHelper.ToNullDBValue(model.ExpreeType)),
                                             new SQLiteParameter("@Expree_Date", SqlHelper.ToNullDBValue(model.ExpreeDate)),
                                             new SQLiteParameter("@Sender_Name", SqlHelper.ToNullDBValue(model.SenderName)),
                                             new SQLiteParameter("@Sender_ZipCode", SqlHelper.ToNullDBValue(model.SenderZipCode)),
                                             new SQLiteParameter("@Sender_Address", SqlHelper.ToNullDBValue(model.SenderAddress)),
                                             new SQLiteParameter("@Sender_Company_Name", SqlHelper.ToNullDBValue(model.SenderCompanyName)),
                                             new SQLiteParameter("@Sender_Phone", SqlHelper.ToNullDBValue(model.SenderPhone))
                                             ));
        }
Exemplo n.º 5
0
 /// <summary>
 /// 根据主键ID更新一条记录
 /// </summary>
 /// <param name="model">更新后的实体</param>
 /// <returns>执行结果受影响行数</returns>
 public int Update(MExpress model)
 {
     return(_dao.Update(model));
 }
Exemplo n.º 6
0
 /// <summary>
 /// 向数据库中添加一条记录
 /// </summary>
 /// <param name="model">要添加的实体</param>
 /// <returns>插入数据的ID</returns>
 public int Insert(MExpress model)
 {
     return(_dao.Insert(model));
 }
Exemplo n.º 7
0
        /// <summary>
        /// 表示需要打印的数据源集合
        /// </summary>
        /// <param name="mList"></param>
        public void Print(MExpress mExpress)
        {
            if (mExpress == null || string.IsNullOrEmpty(mExpress.ExpreeType))
            {
                return;
            }
            m_List = GetPrintResource(mExpress.ExpreeType, mExpress);
            if (m_List == null)
            {
                return;
            }


            PrintDocument mPrintDocument = new PrintDocument();

            //设置打印机
            mPrintDocument.PrinterSettings.PrinterName = m_MPrinter.Printer;
            //设置打印份数
            mPrintDocument.PrinterSettings.Copies = Convert.ToInt16(m_MPrinter.PrintNum);
            //设置打印用的纸张 当设置为Custom的时候,可以自定义纸张的大小,还可以选择A4,A5等常用纸型
            if (m_MPrinter.NowHeight != 0 && m_MPrinter.NowWeight != 0)
            {
                mPrintDocument.DefaultPageSettings.PaperSize = new PaperSize("Custum", Convert.ToInt32(m_MPrinter.NowWeight) / 10, Convert.ToInt32(m_MPrinter.NowHeight) / 10);
            }
            else
            {
                mPrintDocument.DefaultPageSettings.PaperSize = new PaperSize("Custum", Convert.ToInt32(m_MPrinter.IniWeight) / 10, Convert.ToInt32(m_MPrinter.IniHeight) / 10);
            }
            //设置打印方向
            if (m_MPrinter.PrintFoward == "横向")
            {
                mPrintDocument.DefaultPageSettings.Landscape = true;
            }
            else
            {
                mPrintDocument.DefaultPageSettings.Landscape = false;
            }
            //设置打印偏移量
            int topAway  = 0;
            int leftAway = 0;

            if (m_MPrinter.TopAway != 0)
            {
                topAway = Convert.ToInt32(m_MPrinter.TopAway) / 10;
            }
            if (m_MPrinter.LeftAway != 0)
            {
                leftAway = Convert.ToInt32(m_MPrinter.LeftAway) / 10;
            }
            if (topAway >= 0)
            {
                mPrintDocument.DefaultPageSettings.Margins.Top = topAway;
            }
            else
            {
                mPrintDocument.DefaultPageSettings.Margins.Bottom = topAway * -1;
            }
            if (leftAway >= 0)
            {
                mPrintDocument.DefaultPageSettings.Margins.Left = leftAway;
            }
            else
            {
                mPrintDocument.DefaultPageSettings.Margins.Right = leftAway * -1;
            }
            //设置打印内容
            mPrintDocument.PrintPage += mPrintDocument_PrintPage;
            mPrintDocument.Print();

            //更新打印状态
            mExpress.IsPrint = "是";
            m_ExpressBLL.Update(mExpress);
        }
Exemplo n.º 8
0
 /// <summary>
 /// 保存
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void t_tms_Save_Click(object sender, EventArgs e)
 {
     try
     {
         //获取值
         m_Express.ExpressNo  = t_txt_ExpressNum.Text;
         m_Express.ExpreeType = t_cmg_ExpressType.Text;
         if (t_dtp_ExpressDate.Value != null)
         {
             m_Express.ExpreeDate = Convert.ToDateTime(t_dtp_ExpressDate.Value);
         }
         m_Express.SenderName         = t_txt_SenderName.Text;
         m_Express.SenderZipCode      = t_txt_SenderZipCode.Text;
         m_Express.SenderCompanyName  = t_txt_SenderCompanyName.Text;
         m_Express.SenderPhone        = t_txt_SenderPhone.Text;
         m_Express.SenderTel          = t_txt_SenderTel.Text;
         m_Express.ReceiveName        = t_txt_ReceiveName.Text;
         m_Express.ReceiveZipCode     = t_txt_ReceiveZipCode.Text;
         m_Express.ReceiveCompanyName = t_txt_ReceiveCompanyName.Text;
         m_Express.ReceivePhone       = t_txt_ReceivePhone.Text;
         m_Express.ReceiveAddress     = t_txt_ReceiveAddress.Text;
         m_Express.SenderAddress      = t_txt_SenderAddress.Text;
         m_Express.ReceiveTel         = t_txt_ReceiveTel.Text;
         m_Express.GoodsName          = t_txt_GoodsName.Text;
         m_Express.GoodsSize          = t_txt_GoodsSize.Text;
         m_Express.Sum             = t_txt_Sum.Text;
         m_Express.IsStock         = t_cmg_IsStock.Text;
         m_Express.SenderProvince  = t_cmg_SenderPro.Text;
         m_Express.SenderCity      = t_cmg_SenderCity.Text;
         m_Express.ReceiveProvince = t_cmg_ReceivePro.Text;
         m_Express.ReceiveCity     = t_cmg_ReceiveCity.Text;
         //保存
         if (m_Express.Status == "新建")//状态
         {
             if (!BeforeSave(m_Express))
             {
                 return;
             }
             //校验是否已经存在
             MExpress mExpress = mExpressBLL.QueryModel(string.Format("where Express_No='{0}'", m_Express.ExpressNo));
             if (mExpress != null)
             {
                 DialogResult result = this.Question("该快递单号已存在,是否继续保存!");
                 if (result != DialogResult.OK)
                 {
                     return;
                 }
             }
             m_Express.Status = "已保存";
             //插入
             int affectRecrd = mExpressBLL.Insert(m_Express);
             SaveAfter(affectRecrd);
             //更新流水号
             UpdateMaxNum(m_Express.ExpreeType);
         }
         else
         {
             if (!BeforeSave(m_Express))
             {
                 return;
             }
             //更新
             int affectRecrd = mExpressBLL.Update(m_Express);
             SaveAfter(affectRecrd);
         }
     }
     catch (Exception ex)
     {
         this.Warning(ex.Message);
     }
 }