-
C# 发送邮件简单版 附代码
C# 发送邮件简单版 附代码,将string型转换为Base64,发送消息至服务器,本程序成功发送邮件,需要设置smtp服务器、指定发送端口、指定发件人、收件人、邮件主题、内容、发件人密码等信息。
- 2022-07-17 21:27:55下载
- 积分:1
-
C#调用存储过程显示客户的订单金额
Visual C# 通过调用存储过程显示客户的订单金额,获取客户的订单总额(获取存储过程参数的返回值):
private void button1_Click(object sender, EventArgs e)
{//获取客户的订单总额(获取存储过程参数的返回值)
DataClasses1DataContext MyDataContext = new DataClasses1DataContext();
string MyCustomer = "alfki";
decimal? MyAmount = 0;
MyDataContext.CustOrderTotal(MyCustomer, ref MyAmount);
MessageBox.Show(MyCustomer+"客户的订单金额是:"+MyAmount.ToString(),"信息提示",MessageBoxButtons.OK);
}
- 2022-10-21 01:10:03下载
- 积分:1
-
C# 打印XPS文档 XPS文件打印
C# 打印选择的XPS文档,打印XPS文件,相关代码如下:
private void button1_Click(object sender, RoutedEventArgs e)
{//打印选择的XPS文档
var MyDlg = new Microsoft.Win32.OpenFileDialog();
MyDlg.InitialDirectory = System.IO.Directory.GetCurrentDirectory();
MyDlg.Filter = "XPS文件(*.xps)|*.xps|所有文件(*.*)|*.*";
if (MyDlg.ShowDialog() == true)
{
string MyFileName = MyDlg.FileName;
var pDialog = new PrintDialog();
pDialog.PageRangeSelection = PageRangeSelection.AllPages;
pDialog.UserPageRangeEnabled = true;
if (pDialog.ShowDialog() == true)
{
var MyDocument = new System.Windows.Xps.Packaging.XpsDocument(MyFileName, System.IO.FileAccess.ReadWrite);
FixedDocumentSequence MyFixedDocumentSequence = MyDocument.GetFixedDocumentSequence();
pDialog.PrintDocument(MyFixedDocumentSequence.DocumentPaginator, "我的XPS打印文档");
}
}
}
- 2022-03-23 09:37:24下载
- 积分:1
-
C# 禁止鼠标左键单击的实现源码
C# 禁止鼠标左键单击,附上例子源码,禁止后将不响应鼠标左键消息,当然也可恢复鼠标左键,直接关闭本程序即可恢复,实现方法也很简单,看如下代码:
private void button1_Click(object sender, EventArgs e)
{//禁止鼠标左键单击
Application.AddMessageFilter(this);
MessageBox.Show("鼠标左键已经被禁止,请用Tab键执行操作!", "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
private void button2_Click(object sender, EventArgs e)
{//允许鼠标左键单击
Application.RemoveMessageFilter(this);
MessageBox.Show("鼠标左键已经被解禁,可以执行操作!", "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
public bool PreFilterMessage(ref System.Windows.Forms.Message MySystemMessage)
{//不响应鼠标左键消息
if (MySystemMessage.Msg >= 513 && MySystemMessage.Msg
- 2022-03-09 09:45:43下载
- 积分:1
-
C# 显示使用LINQ to SQL类查询的数据库记录
C# 显示使用LINQ to SQL类查询的数据库记录,使用LINQ模型创建LINQ to SQL类。
- 2022-07-19 08:46:45下载
- 积分:1
-
C# 使用字符串数组创建一组单选框数据
C# 基于字符串数组创建一组单选按钮的例子,附上了例子源代码,大家可了解C#字符串数组的简单应用。
以下是例子中的代码,运行后可见如下图所示的图片效果:
//基于字符串数组创建一组单选按钮
string[] MyArray = new string[4];
MyArray[0] = "渝北区";
MyArray[1] = "巴南区";
MyArray[2] = "长寿区";
MyArray[3] = "南岸区";
RadioButton[] MyRadioButtons =new RadioButton[4];
for (int i = 0; i < 4; ++i)
{
MyRadioButtons[i] = new RadioButton();
MyRadioButtons[i].Text = MyArray[i];
MyRadioButtons[i].Location = new System.Drawing.Point(
10, 20 + i * 20);
this.groupBox1.Controls.Add(MyRadioButtons[i]);
}
this.groupBox1.Text = "请评选全市卫生城区:";
- 2022-02-27 00:14:46下载
- 积分:1
-
C# 使用ODBC非DSN连接SQL Server数据库
C# NoDSN功能实例,使用ODBC非DSN连接SQL Server数据库,string odbcConStr =//创建数据库连接字符串
@"driver=SQL Server;server=WIN-GI7E47AND9RLS;UID=sa;PWD=;database=db_TomeTwo";
OdbcConnection odbcCon = new OdbcConnection(odbcConStr);//创建数据库连接对象
OdbcDataAdapter da =//创建数据适配器对象
new OdbcDataAdapter("select * from 帐单", odbcCon);
DataTable dt = new DataTable();//创建数据表
da.Fill(dt);//填充数据表
this.dgv_Message.DataSource =//设置数据源
dt.DefaultView;
}
- 2023-03-02 09:35:03下载
- 积分:1
-
C# 与windows操作自定义函数合集
C# 与windows操作自定义函数合集,包括了以下自定义函数:获取系统服务程序的状态信息、创建并写入自定义日志信息、向系统日志写入自定义数据、向应用程序日志写入自定义数据、判断当前操作用户的管理角色、判断与鼠标单击联动的修改键、判断启动的指定程序是否已关闭、使用API函数发送消息关闭程序、获取当前系统正在运行的程序、限制应用程序的运行时间、使用画图程序打开一个图像文件、以最大化窗口启动记事本程序、直接从应用程序返回到桌面、获取应用程序的版权信息等。
- 2023-09-02 15:40:03下载
- 积分:1
-
STM32F1的SPWM逆变器源码
#include "SPWM.h"
#include "led.h"
#include "usart.h"
u16 TimerPeriod = 7200;
u16 DutyFactor = 50;
void TIM_Int_Init(void)
{
GPIO_InitTypeDef GPIO_InitStructure;
TIM_TimeBaseInitTypeDef TIM_TimeBaseStructure;
NVIC_InitTypeDef NVIC_InitStructure;
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA | RCC_APB2Periph_GPIOB, ENABLE);
RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM4 | RCC_APB1Periph_TIM3,ENABLE); //时钟使能
/* GPIOA配置:通道PA.6和PA.7作为输出引脚*/
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_6 | GPIO_Pin_7;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
&nbs
- 2022-07-26 17:50:34下载
- 积分:1
-
C# WPF设置图片做为程序窗口背景
C# WPF设置程序窗口背景图片的例子,调用外部一张图片,作为程序窗口的背景,这是一个挺基础的C#窗口设计制作小例子。本程序通过定义BitmapImage和ImageBrush()来实现,有兴趣的参见以下几行代码:
设置WPF程序的背景图像代码如下:
var MyImage = new BitmapImage(new Uri("J001.jpg", UriKind.Relative));
var MyBrush = new ImageBrush();
MyBrush.ImageSource = MyImage;
this.Background = MyBrush;
本例的运行效果请参见下图示。
- 2022-02-28 22:19:19下载
- 积分:1