📄 vacationsetting.cs
字号:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;
namespace BlueHill_Win_
{
public partial class VacationSetting : Form
{
public VacationSetting()
{
InitializeComponent();
}
private void btnCancel_Click(object sender, EventArgs e)
{
this.Hide();
VacationManagement VM = new VacationManagement();
VM.Show();
}
private void BtnAddVaction_Click(object sender, EventArgs e)
{
SqlConnection con = DB.connection();
con.Open();
if ( textBox1.Text.Trim() !="")
{
if (checkBox1.Checked == true)
{
SqlCommand cmd = new SqlCommand("insert into 假期表 values ('" + dateTimePicker1.Value.ToShortDateString() + "','" + textBox1.Text.ToString().Trim() + "','" + true + "')",con);
int count = Convert.ToInt32(cmd.ExecuteNonQuery());
if (count > 0)
{
DialogResult = MessageBox.Show("添加成功!", "提示");
}
else
DialogResult = MessageBox.Show("操作失败!", "提示");
}
else
{
SqlCommand cmd1 = new SqlCommand("insert into 假期表 values ('" + dateTimePicker1.Value.ToShortDateString() + "','" + textBox1.Text.ToString().Trim() + "','" + false + "')",con);
int count1 = Convert.ToInt32(cmd1.ExecuteNonQuery());
if (count1 > 0)
{
DialogResult = MessageBox.Show("添加成功!", "提示");
}
else
DialogResult = MessageBox.Show("操作失败!", "提示");
}
con.Close();
}
else
DialogResult = MessageBox.Show("请输入假期名称!", "提示");
textBox1.Focus();
}
private void VacationSetting_Load(object sender, EventArgs e)
{
SqlConnection con = DB.connection();
con.Open();
string cmd = "select * from 假期表";
DataSet ds=new DataSet();
SqlDataAdapter sda=new SqlDataAdapter(cmd,con);
sda.Fill(ds,"假期表");
this.checkedListBox1.DataSource = ds.Tables["假期表"];
this.checkedListBox1.ValueMember = "假期编号";
this.checkedListBox1.DisplayMember = "假期名称";
//checkedListBox1.DataBindings.Add(0);
//for (int i = 0; i < checkedListBox1.Items.Count; i++)
//{
// DataRowView dv = ((DataRowView)checkedListBox1.Items[i]);
// string dd = dv["假期编号"].ToString();
// if (strLimit.LastIndexOf("," + dd + ",") != -1)
// {
// checkedListBox1.SetItemChecked(i, true);
// }
//}
con.Close();
}
private void BtnDelVaction_Click(object sender, EventArgs e)
{
MessageBox.Show(checkedListBox1.SelectedItems.ToString());
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -