⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 diary.cs

📁 个人信息管理系统
💻 CS
📖 第 1 页 / 共 2 页
字号:
			this.btnedit.Size = new System.Drawing.Size(40, 23);
			this.btnedit.TabIndex = 11;
			this.btnedit.Text = "修改";
			this.btnedit.Click += new System.EventHandler(this.btnedit_Click);
			// 
			// btndel
			// 
			this.btndel.Location = new System.Drawing.Point(288, 416);
			this.btndel.Name = "btndel";
			this.btndel.Size = new System.Drawing.Size(40, 23);
			this.btndel.TabIndex = 11;
			this.btndel.Text = "删除";
			this.btndel.Click += new System.EventHandler(this.btndel_Click);
			// 
			// btnweather1
			// 
			this.btnweather1.Image = ((System.Drawing.Image)(resources.GetObject("btnweather1.Image")));
			this.btnweather1.Location = new System.Drawing.Point(104, 112);
			this.btnweather1.Name = "btnweather1";
			this.btnweather1.Size = new System.Drawing.Size(32, 24);
			this.btnweather1.TabIndex = 12;
			// 
			// label5
			// 
			this.label5.Location = new System.Drawing.Point(16, 112);
			this.label5.Name = "label5";
			this.label5.Size = new System.Drawing.Size(64, 23);
			this.label5.TabIndex = 13;
			this.label5.Text = "天气:";
			// 
			// btnweather3
			// 
			this.btnweather3.Image = ((System.Drawing.Image)(resources.GetObject("btnweather3.Image")));
			this.btnweather3.Location = new System.Drawing.Point(176, 112);
			this.btnweather3.Name = "btnweather3";
			this.btnweather3.Size = new System.Drawing.Size(32, 24);
			this.btnweather3.TabIndex = 12;
			// 
			// btnweather4
			// 
			this.btnweather4.Image = ((System.Drawing.Image)(resources.GetObject("btnweather4.Image")));
			this.btnweather4.Location = new System.Drawing.Point(216, 112);
			this.btnweather4.Name = "btnweather4";
			this.btnweather4.Size = new System.Drawing.Size(32, 24);
			this.btnweather4.TabIndex = 12;
			// 
			// btnweather5
			// 
			this.btnweather5.Image = ((System.Drawing.Image)(resources.GetObject("btnweather5.Image")));
			this.btnweather5.Location = new System.Drawing.Point(256, 112);
			this.btnweather5.Name = "btnweather5";
			this.btnweather5.Size = new System.Drawing.Size(32, 24);
			this.btnweather5.TabIndex = 12;
			// 
			// btnweather2
			// 
			this.btnweather2.Checked = true;
			this.btnweather2.Image = ((System.Drawing.Image)(resources.GetObject("btnweather2.Image")));
			this.btnweather2.Location = new System.Drawing.Point(144, 112);
			this.btnweather2.Name = "btnweather2";
			this.btnweather2.Size = new System.Drawing.Size(32, 24);
			this.btnweather2.TabIndex = 12;
			this.btnweather2.TabStop = true;
			// 
			// btnweather6
			// 
			this.btnweather6.Image = ((System.Drawing.Image)(resources.GetObject("btnweather6.Image")));
			this.btnweather6.Location = new System.Drawing.Point(304, 112);
			this.btnweather6.Name = "btnweather6";
			this.btnweather6.Size = new System.Drawing.Size(32, 24);
			this.btnweather6.TabIndex = 12;
			// 
			// label6
			// 
			this.label6.Location = new System.Drawing.Point(16, 56);
			this.label6.Name = "label6";
			this.label6.Size = new System.Drawing.Size(24, 23);
			this.label6.TabIndex = 14;
			this.label6.Text = "ID";
			// 
			// txtid
			// 
			this.txtid.Location = new System.Drawing.Point(56, 56);
			this.txtid.Name = "txtid";
			this.txtid.Size = new System.Drawing.Size(24, 21);
			this.txtid.TabIndex = 15;
			this.txtid.Text = "";
			// 
			// diary
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
			this.BackColor = System.Drawing.Color.FromArgb(((System.Byte)(235)), ((System.Byte)(246)), ((System.Byte)(255)));
			this.ClientSize = new System.Drawing.Size(352, 500);
			this.Controls.Add(this.txtid);
			this.Controls.Add(this.txtpage);
			this.Controls.Add(this.txttitle);
			this.Controls.Add(this.txttime);
			this.Controls.Add(this.label6);
			this.Controls.Add(this.label5);
			this.Controls.Add(this.btnweather1);
			this.Controls.Add(this.btnedit);
			this.Controls.Add(this.label2);
			this.Controls.Add(this.lbltotal);
			this.Controls.Add(this.rtbdiary);
			this.Controls.Add(this.btnfirst);
			this.Controls.Add(this.label1);
			this.Controls.Add(this.pictureBox1);
			this.Controls.Add(this.label3);
			this.Controls.Add(this.label4);
			this.Controls.Add(this.btnpre);
			this.Controls.Add(this.btnnext);
			this.Controls.Add(this.btnlast);
			this.Controls.Add(this.btndel);
			this.Controls.Add(this.btnweather3);
			this.Controls.Add(this.btnweather4);
			this.Controls.Add(this.btnweather5);
			this.Controls.Add(this.btnweather2);
			this.Controls.Add(this.btnweather6);
			this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.Fixed3D;
			this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
			this.MaximizeBox = false;
			this.MinimizeBox = false;
			this.Name = "diary";
			this.Text = "个人信息管理系统";
			this.Load += new System.EventHandler(this.diary_Load);
			this.ResumeLayout(false);

		}
		#endregion

		private void diary_Load(object sender, System.EventArgs e)
		{
			datalink mydl=new datalink();
			string sql="select *from diary order by diary_id desc";
			string table="diary";
			myds=mydl.dataset(sql,table);
			navigator=this.BindingContext[myds,"diary"];
			this.txttitle.DataBindings.Add("Text",myds,"diary.diary_title");
			this.txttime.DataBindings.Add("Text",myds,"diary.diary_time");
			this.rtbdiary.DataBindings.Add("Text",myds,"diary.diary_content");
			this.txtid.DataBindings.Add("Text",myds,"diary.diary_id");
			this.lbltotal.Text=navigator.Count.ToString();
		}

		private void btnfirst_Click(object sender, System.EventArgs e)
		{
			navigator.Position=0;
		}

		private void btnlast_Click(object sender, System.EventArgs e)
		{
			navigator.Position=navigator.Count-1;

		}

		private void btnpre_Click(object sender, System.EventArgs e)
		{
			if(navigator.Position==0)
				navigator.Position=navigator.Count-1;
			else
				navigator.Position-=0;
		}

		private void btnnext_Click(object sender, System.EventArgs e)
		{
			if(navigator.Position==navigator.Count-1)
				navigator.Position=0;
			else
				navigator.Position+=1;
		}

		private void txtpage_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e)
		{
			if(e.KeyValue==13)
			{
				navigator.Position=Int32.Parse(txtpage.Text)-1;
			}
		}

		private void btndel_Click(object sender, System.EventArgs e)
		{
			if(txtid.Text=="")
			{
				MessageBox.Show("必须输入ID!");
			}
			else
			{
				if(MessageBox.Show("你确实要删除吗?","友情提醒",MessageBoxButtons.OKCancel,MessageBoxIcon.Information)==DialogResult.OK)
					
				{
					string sql="delete from diary where diary_id=";
					sql+=txtid.Text.Trim();
					datalink mydatalink=new datalink();
					if(mydatalink.executesql(sql)==true)
						MessageBox.Show("删除成功!");
					else
						MessageBox.Show("删除失败!");
				}
			}
		}

		private void btnedit_Click(object sender, System.EventArgs e)
		{
			if(txtid.Text=="")
			{
				MessageBox.Show("必须输入ID!");
			}
			else
			{
				if(txttitle.Text==""||rtbdiary.Text=="")
					MessageBox.Show("请填写完整信息!");
				else
				{
					datalink mydatalink=new datalink();
					string weather="";
					if(btnweather1.Checked==true) weather="images/weather1.gif";
					if(btnweather2.Checked==true) weather="images/weather2.gif";
					if(btnweather3.Checked==true) weather="images/weather3.gif";
					if(btnweather4.Checked==true) weather="images/weather4.gif";
					if(btnweather5.Checked==true) weather="images/weather5.gif";
					if(btnweather6.Checked==true) weather="images/weather6.gif";
					string sql="update diary set diary_time='"+txttime.Text+"',diary_title='"+txttitle.Text+"',diary_content='"+rtbdiary.Text+"',diary_weather='"+weather+"'where diary_id=";
					sql+=txtid.Text.Trim();
					if(mydatalink.executesql(sql))
						MessageBox.Show("编辑成功!");
					else
						MessageBox.Show("编辑失败!");
				}


			}
		}
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -