1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725
| using System; using System.Data; using System.Data.SqlClient; using System.Windows.Forms; using System.Drawing; using System.Threading;
namespace 大学实验材料管理信息系统数据库设计 { public partial class student : Form { public student() {
SqlConnection conn = new(login.connectket); InitializeComponent(); textBox1.Text = login.id; textBox2.Text = DateTime.Now.ToString("yyyy/MM/dd " + "ddd"); SqlCommand com = new SqlCommand("select STNA from ST where STNO='" + login.id + "'", conn); conn.Open(); SqlDataReader dr = com.ExecuteReader(); dr.Read(); string hello = "欢迎您" + dr[0].ToString().Trim() + "!"; label7.Text = hello; dr.Dispose(); com.Dispose(); DataSet ds1 = new DataSet(); DataSet ds2 = new DataSet(); SqlDataAdapter da = new SqlDataAdapter("select distinct MSLNO from MS ", conn); SqlDataAdapter db = new SqlDataAdapter("select distinct MSLNO from BO where STNO = '" + login.id + "'", conn); da.Fill(ds1); db.Fill(ds2); comboBox1.DataSource = ds1.Tables[0].DefaultView; comboBox1.DisplayMember = "MSLNO"; comboBox3.DataSource = ds2.Tables[0].DefaultView; comboBox3.DisplayMember = "MSLNO"; int count = comboBox1.Items.Count; comboBox1.SelectedIndex = -1; comboBox3.SelectedIndex = -1; SqlDataAdapter sda = new SqlDataAdapter("select MSNA AS 材料名,MSNO AS 材料编号,MSLNA AS 实验室名称,MSLNO AS 实验室编号,MSNU AS 材料余量 from MS", conn); DataSet ds = new DataSet(); sda.Fill(ds); dataGridView1.DataSource = ds.Tables[0]; dataGridView1.RowHeadersVisible = true; SqlCommand cmd6 = new SqlCommand("select count(*) from BO where (" + Convert.ToInt32(login.today) + "-RTDA)>='" + 0 + "' AND STNO = '" + login.id + "'", conn); SqlDataAdapter adapter = new SqlDataAdapter(); adapter.SelectCommand = cmd6; int getw = (int)cmd6.ExecuteScalar(); if (getw > 0) { MessageBox.Show("您有" + getw + "条已过期未还材料记录,请及时归还材料!", "提示"); } conn.Close(); }
string returnday;
private void button1_Click(object sender, EventArgs e) { this.Hide(); login form1 = new login(); form1.Show(); }
private void button2_Click(object sender, EventArgs e) { this.Close(); }
private void button3_Click(object sender, EventArgs e) { SqlConnection conn = new(login.connectket); SqlDataAdapter sda = new SqlDataAdapter("select MSNA AS 材料名,MSNO AS 材料编号,MSLNA AS 实验室名称,MSLNO AS 实验室编号,MSNU AS 材料余量 from MS", conn); DataSet ds = new DataSet(); sda.Fill(ds); dataGridView1.DataSource = ds.Tables[0]; dataGridView1.RowHeadersVisible = true; conn.Close(); }
private void textBox1_TextChanged(object sender, EventArgs e) {
}
private void button4_Click(object sender, EventArgs e) { dataGridView2.DataSource = null; SqlConnection conn = new(login.connectket); SqlDataAdapter sda = new SqlDataAdapter("select MSNO AS 材料编号,MSLNO AS 材料所属实验室,BONU AS 材料数量,BODA AS 借用日期,RTDA AS 预计归还日期 from BO WHERE STNO ='" + login.id + "'", conn); DataSet ds = new DataSet(); sda.Fill(ds); dataGridView2.DataSource = ds.Tables[0]; dataGridView2.RowHeadersVisible = true; int n = dataGridView2.Rows.Count; for (int i = 0; i < n - 1; i++) { if (Convert.ToInt32(dataGridView2.Rows[i].Cells[4].Value) > Convert.ToInt32(login.today)) { dataGridView2.Rows[i].Cells[0].Style.BackColor = System.Drawing.Color.LightGreen; dataGridView2.Rows[i].Cells[1].Style.BackColor = System.Drawing.Color.LightGreen; dataGridView2.Rows[i].Cells[2].Style.BackColor = System.Drawing.Color.LightGreen; dataGridView2.Rows[i].Cells[3].Style.BackColor = System.Drawing.Color.LightGreen; dataGridView2.Rows[i].Cells[4].Style.BackColor = System.Drawing.Color.LightGreen; } else if (Convert.ToInt32(dataGridView2.Rows[i].Cells[4].Value) == Convert.ToInt32(login.today)) { dataGridView2.Rows[i].Cells[0].Style.BackColor = System.Drawing.Color.Yellow; dataGridView2.Rows[i].Cells[1].Style.BackColor = System.Drawing.Color.Yellow; dataGridView2.Rows[i].Cells[2].Style.BackColor = System.Drawing.Color.Yellow; dataGridView2.Rows[i].Cells[3].Style.BackColor = System.Drawing.Color.Yellow; dataGridView2.Rows[i].Cells[4].Style.BackColor = System.Drawing.Color.Yellow; } else { dataGridView2.Rows[i].Cells[0].Style.BackColor = System.Drawing.Color.Red; dataGridView2.Rows[i].Cells[1].Style.BackColor = System.Drawing.Color.Red; dataGridView2.Rows[i].Cells[2].Style.BackColor = System.Drawing.Color.Red; dataGridView2.Rows[i].Cells[3].Style.BackColor = System.Drawing.Color.Red; dataGridView2.Rows[i].Cells[4].Style.BackColor = System.Drawing.Color.Red; } } conn.Close(); }
private void tabPage3_Click(object sender, EventArgs e) {
}
private void student_Load(object sender, EventArgs e) {
}
private void button5_Click(object sender, EventArgs e) { dataGridView2.DataSource = null; SqlConnection conn = new(login.connectket); SqlDataAdapter sday = new SqlDataAdapter("select MSNO AS 材料编号,MSLNO AS 材料所属实验室,BONU AS 材料数量,BODA AS 借用日期,RTDA AS 归还日期 from RC WHERE STNO ='" + login.id + "'", conn); DataSet dsy = new DataSet(); sday.Fill(dsy); dataGridView2.DataSource = dsy.Tables[0]; dataGridView2.RowHeadersVisible = true; conn.Close(); }
private void button7_Click(object sender, EventArgs e) { textBox3.Text = ""; textBox4.Text = ""; textBox5.Text = ""; }
private void button6_Click(object sender, EventArgs e) { SqlConnection conn = new(login.connectket); if (textBox3.Text.Trim() != "" && textBox4.Text.Trim() != "" && textBox5.Text.Trim() != "") { SqlCommand cmd3 = new SqlCommand("select count(*) from ST where STNO = '" + login.id + "'", conn); conn.Open(); int b = (int)cmd3.ExecuteScalar(); if (b == 1) { SqlCommand cmd4 = new SqlCommand("select STKE from ST where STNO = '" + login.id + "'", conn); string c = cmd4.ExecuteScalar().ToString().Trim(); string oldpwd = login.GetSHA256HashFromString(textBox3.Text.ToString().Trim()); string newpwd = login.GetSHA256HashFromString(textBox4.Text.ToString().Trim()); string dnewpwd = login.GetSHA256HashFromString(textBox5.Text.ToString().Trim());
if (newpwd == dnewpwd) { if (c == oldpwd) { if (oldpwd != newpwd) { SqlCommand cmd5 = new SqlCommand("update ST set STKE = '" + newpwd + "'where STNO = '" + login.id + "'", conn); int k = (int)cmd5.ExecuteNonQuery(); if (k > 0) { MessageBox.Show("密码修改成功,请重新登录!", "提示"); this.Hide(); login form1 = new login(); form1.Show(); } else { this.Location = new Point(this.Left + 10, this.Top); Thread.Sleep(1); this.Location = new Point(this.Left, this.Top + 10); Thread.Sleep(1); this.Location = new Point(this.Left - 10, this.Top); Thread.Sleep(1); this.Location = new Point(this.Left - 10, this.Top); Thread.Sleep(1); this.Location = new Point(this.Left, this.Top - 10); Thread.Sleep(1); this.Location = new Point(this.Left, this.Top - 10); Thread.Sleep(1); this.Location = new Point(this.Left + 10, this.Top); Thread.Sleep(1); this.Location = new Point(this.Left + 10, this.Top); Thread.Sleep(1); this.Location = new Point(this.Left, this.Top + 10); Thread.Sleep(1); this.Location = new Point(this.Left - 10, this.Top); MessageBox.Show("密码修改失败!", "提示"); textBox3.Text = ""; textBox4.Text = ""; textBox5.Text = ""; } } else { this.Location = new Point(this.Left + 10, this.Top); Thread.Sleep(1); this.Location = new Point(this.Left, this.Top + 10); Thread.Sleep(1); this.Location = new Point(this.Left - 10, this.Top); Thread.Sleep(1); this.Location = new Point(this.Left - 10, this.Top); Thread.Sleep(1); this.Location = new Point(this.Left, this.Top - 10); Thread.Sleep(1); this.Location = new Point(this.Left, this.Top - 10); Thread.Sleep(1); this.Location = new Point(this.Left + 10, this.Top); Thread.Sleep(1); this.Location = new Point(this.Left + 10, this.Top); Thread.Sleep(1); this.Location = new Point(this.Left, this.Top + 10); Thread.Sleep(1); this.Location = new Point(this.Left - 10, this.Top); MessageBox.Show("新旧密码不能一样!", "提示"); textBox4.Text = ""; textBox5.Text = ""; } } else { this.Location = new Point(this.Left + 10, this.Top); Thread.Sleep(1); this.Location = new Point(this.Left, this.Top + 10); Thread.Sleep(1); this.Location = new Point(this.Left - 10, this.Top); Thread.Sleep(1); this.Location = new Point(this.Left - 10, this.Top); Thread.Sleep(1); this.Location = new Point(this.Left, this.Top - 10); Thread.Sleep(1); this.Location = new Point(this.Left, this.Top - 10); Thread.Sleep(1); this.Location = new Point(this.Left + 10, this.Top); Thread.Sleep(1); this.Location = new Point(this.Left + 10, this.Top); Thread.Sleep(1); this.Location = new Point(this.Left, this.Top + 10); Thread.Sleep(1); this.Location = new Point(this.Left - 10, this.Top); MessageBox.Show("原密码填写错误!", "提示"); textBox3.Text = ""; textBox4.Text = ""; textBox5.Text = ""; } } else { this.Location = new Point(this.Left + 10, this.Top); Thread.Sleep(1); this.Location = new Point(this.Left, this.Top + 10); Thread.Sleep(1); this.Location = new Point(this.Left - 10, this.Top); Thread.Sleep(1); this.Location = new Point(this.Left - 10, this.Top); Thread.Sleep(1); this.Location = new Point(this.Left, this.Top - 10); Thread.Sleep(1); this.Location = new Point(this.Left, this.Top - 10); Thread.Sleep(1); this.Location = new Point(this.Left + 10, this.Top); Thread.Sleep(1); this.Location = new Point(this.Left + 10, this.Top); Thread.Sleep(1); this.Location = new Point(this.Left, this.Top + 10); Thread.Sleep(1); this.Location = new Point(this.Left - 10, this.Top); MessageBox.Show("两次新密码不一致!", "提示"); textBox4.Text = ""; textBox5.Text = ""; } } else { this.Location = new Point(this.Left + 10, this.Top); Thread.Sleep(1); this.Location = new Point(this.Left, this.Top + 10); Thread.Sleep(1); this.Location = new Point(this.Left - 10, this.Top); Thread.Sleep(1); this.Location = new Point(this.Left - 10, this.Top); Thread.Sleep(1); this.Location = new Point(this.Left, this.Top - 10); Thread.Sleep(1); this.Location = new Point(this.Left, this.Top - 10); Thread.Sleep(1); this.Location = new Point(this.Left + 10, this.Top); Thread.Sleep(1); this.Location = new Point(this.Left + 10, this.Top); Thread.Sleep(1); this.Location = new Point(this.Left, this.Top + 10); Thread.Sleep(1); this.Location = new Point(this.Left - 10, this.Top); MessageBox.Show("用户名不存在请重新登录!", "提示"); this.Hide(); login form1 = new login(); form1.Show(); } conn.Close(); } else { this.Location = new Point(this.Left + 10, this.Top); Thread.Sleep(1); this.Location = new Point(this.Left, this.Top + 10); Thread.Sleep(1); this.Location = new Point(this.Left - 10, this.Top); Thread.Sleep(1); this.Location = new Point(this.Left - 10, this.Top); Thread.Sleep(1); this.Location = new Point(this.Left, this.Top - 10); Thread.Sleep(1); this.Location = new Point(this.Left, this.Top - 10); Thread.Sleep(1); this.Location = new Point(this.Left + 10, this.Top); Thread.Sleep(1); this.Location = new Point(this.Left + 10, this.Top); Thread.Sleep(1); this.Location = new Point(this.Left, this.Top + 10); Thread.Sleep(1); this.Location = new Point(this.Left - 10, this.Top); MessageBox.Show("密码不能为空!", "提示"); } }
private void textBox4_TextChanged(object sender, EventArgs e) {
}
private void groupBox1_Enter(object sender, EventArgs e) {
}
private void label10_Click(object sender, EventArgs e) {
}
private void dateTimePicker1_ValueChanged(object sender, EventArgs e) { returnday = dateTimePicker1.Value.ToString("yyyyMMdd"); textBox7.Text = dateTimePicker1.Value.ToString("D"); }
private void button9_Click(object sender, EventArgs e) { comboBox2.DataSource = null; comboBox1.SelectedIndex = -1; comboBox2.SelectedIndex = -1; this.numericUpDown1.DecimalPlaces = 0; this.numericUpDown1.Value = Decimal.Round(1, 0); textBox7.Text = ""; returnday = ""; this.dateTimePicker1.Format = DateTimePickerFormat.Custom; this.dateTimePicker1.CustomFormat = ""; this.dateTimePicker1.Checked = false;
}
private void button8_Click(object sender, EventArgs e) { SqlConnection conn = new(login.connectket); if (comboBox1.Text.Trim() == "") { this.Location = new Point(this.Left + 10, this.Top); Thread.Sleep(1); this.Location = new Point(this.Left, this.Top + 10); Thread.Sleep(1); this.Location = new Point(this.Left - 10, this.Top); Thread.Sleep(1); this.Location = new Point(this.Left - 10, this.Top); Thread.Sleep(1); this.Location = new Point(this.Left, this.Top - 10); Thread.Sleep(1); this.Location = new Point(this.Left, this.Top - 10); Thread.Sleep(1); this.Location = new Point(this.Left + 10, this.Top); Thread.Sleep(1); this.Location = new Point(this.Left + 10, this.Top); Thread.Sleep(1); this.Location = new Point(this.Left, this.Top + 10); Thread.Sleep(1); this.Location = new Point(this.Left - 10, this.Top); MessageBox.Show("实验室编号,材料编号为空!", "提示"); } else { if (comboBox2.Text.Trim() == "") { this.Location = new Point(this.Left + 10, this.Top); Thread.Sleep(1); this.Location = new Point(this.Left, this.Top + 10); Thread.Sleep(1); this.Location = new Point(this.Left - 10, this.Top); Thread.Sleep(1); this.Location = new Point(this.Left - 10, this.Top); Thread.Sleep(1); this.Location = new Point(this.Left, this.Top - 10); Thread.Sleep(1); this.Location = new Point(this.Left, this.Top - 10); Thread.Sleep(1); this.Location = new Point(this.Left + 10, this.Top); Thread.Sleep(1); this.Location = new Point(this.Left + 10, this.Top); Thread.Sleep(1); this.Location = new Point(this.Left, this.Top + 10); Thread.Sleep(1); this.Location = new Point(this.Left - 10, this.Top); MessageBox.Show("材料编号为空!", "提示"); } else { string labid = comboBox1.Text.Trim(); string material = comboBox2.Text.Trim(); int num = Convert.ToInt32(numericUpDown1.Value.ToString().Trim()); returnday = dateTimePicker1.Value.ToString("yyyyMMdd"); SqlCommand cmd4 = new SqlCommand("select MSNU from MS where MSNO = '" + material + "' AND MSLNO = '" + labid + "'", conn); SqlCommand cmd5 = new SqlCommand("select MSDP from MS where MSNO = '" + material + "' AND MSLNO = '" + labid + "'", conn); conn.Open(); int c = Convert.ToInt32(cmd4.ExecuteScalar().ToString()); int d = Convert.ToInt32(cmd5.ExecuteScalar().ToString()); conn.Close(); if (d == 1) { if (textBox7.Text.Trim() == "") { this.Location = new Point(this.Left + 10, this.Top); Thread.Sleep(1); this.Location = new Point(this.Left, this.Top + 10); Thread.Sleep(1); this.Location = new Point(this.Left - 10, this.Top); Thread.Sleep(1); this.Location = new Point(this.Left - 10, this.Top); Thread.Sleep(1); this.Location = new Point(this.Left, this.Top - 10); Thread.Sleep(1); this.Location = new Point(this.Left, this.Top - 10); Thread.Sleep(1); this.Location = new Point(this.Left + 10, this.Top); Thread.Sleep(1); this.Location = new Point(this.Left + 10, this.Top); Thread.Sleep(1); this.Location = new Point(this.Left, this.Top + 10); Thread.Sleep(1); this.Location = new Point(this.Left - 10, this.Top); MessageBox.Show("该材料需要归还,请填写归还日期!", "提示"); } else if (Convert.ToInt32(login.today.Trim()) > Convert.ToInt32(returnday)) { this.Location = new Point(this.Left + 10, this.Top); Thread.Sleep(1); this.Location = new Point(this.Left, this.Top + 10); Thread.Sleep(1); this.Location = new Point(this.Left - 10, this.Top); Thread.Sleep(1); this.Location = new Point(this.Left - 10, this.Top); Thread.Sleep(1); this.Location = new Point(this.Left, this.Top - 10); Thread.Sleep(1); this.Location = new Point(this.Left, this.Top - 10); Thread.Sleep(1); this.Location = new Point(this.Left + 10, this.Top); Thread.Sleep(1); this.Location = new Point(this.Left + 10, this.Top); Thread.Sleep(1); this.Location = new Point(this.Left, this.Top + 10); Thread.Sleep(1); this.Location = new Point(this.Left - 10, this.Top); MessageBox.Show("归还日期不能早于今天!", "提示"); textBox7.Text = ""; returnday = ""; } else { if (c >= num) { SqlCommand cmd = new SqlCommand("insert into BO(STNO,MSLNO,MSNO,BONU,BODA,RTDA,CODE) values ('" + login.id + "','" + labid + "','" + material + "','" + num + "','" + login.today + "','" + returnday + "','" + login.GenerateRandom(10) + "')", conn); SqlCommand cmd1 = new SqlCommand("insert into RC(STNO,MSLNO,MSNO,BONU,BODA) values ('" + login.id + "','" + labid + "','" + material + "','" + num + "','" + login.today + "')", conn); try { conn.Open(); cmd.ExecuteNonQuery(); cmd1.ExecuteNonQuery(); int res = c - num; if (res == 0) { SqlCommand cmd2 = new SqlCommand("delete from MS where MSNO = '" + material + "' AND MSLNO = '" + labid + "'", conn); try { cmd2.ExecuteNonQuery(); MessageBox.Show("该材料需要归还,借用成功!"); } catch (Exception ex) { this.Location = new Point(this.Left + 10, this.Top); Thread.Sleep(1); this.Location = new Point(this.Left, this.Top + 10); Thread.Sleep(1); this.Location = new Point(this.Left - 10, this.Top); Thread.Sleep(1); this.Location = new Point(this.Left - 10, this.Top); Thread.Sleep(1); this.Location = new Point(this.Left, this.Top - 10); Thread.Sleep(1); this.Location = new Point(this.Left, this.Top - 10); Thread.Sleep(1); this.Location = new Point(this.Left + 10, this.Top); Thread.Sleep(1); this.Location = new Point(this.Left + 10, this.Top); Thread.Sleep(1); this.Location = new Point(this.Left, this.Top + 10); Thread.Sleep(1); this.Location = new Point(this.Left - 10, this.Top); MessageBox.Show("删除原数据失败!失败原因:" + ex.Message.ToString(), "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information); } } else { SqlCommand cmd2 = new SqlCommand("update MS set MSNU = '" + res + "'where MSNO = '" + material + "' AND MSLNO = '" + labid + "'", conn); try { cmd2.ExecuteNonQuery(); MessageBox.Show("该材料需要归还,借用成功!"); this.Hide(); student form1 = new student(); form1.Show(); } catch (Exception ex) { this.Location = new Point(this.Left + 10, this.Top); Thread.Sleep(1); this.Location = new Point(this.Left, this.Top + 10); Thread.Sleep(1); this.Location = new Point(this.Left - 10, this.Top); Thread.Sleep(1); this.Location = new Point(this.Left - 10, this.Top); Thread.Sleep(1); this.Location = new Point(this.Left, this.Top - 10); Thread.Sleep(1); this.Location = new Point(this.Left, this.Top - 10); Thread.Sleep(1); this.Location = new Point(this.Left + 10, this.Top); Thread.Sleep(1); this.Location = new Point(this.Left + 10, this.Top); Thread.Sleep(1); this.Location = new Point(this.Left, this.Top + 10); Thread.Sleep(1); this.Location = new Point(this.Left - 10, this.Top); MessageBox.Show("删除原数据失败!失败原因:" + ex.Message.ToString(), "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information); } } conn.Close(); } catch (Exception ex) { this.Location = new Point(this.Left + 10, this.Top); Thread.Sleep(1); this.Location = new Point(this.Left, this.Top + 10); Thread.Sleep(1); this.Location = new Point(this.Left - 10, this.Top); Thread.Sleep(1); this.Location = new Point(this.Left - 10, this.Top); Thread.Sleep(1); this.Location = new Point(this.Left, this.Top - 10); Thread.Sleep(1); this.Location = new Point(this.Left, this.Top - 10); Thread.Sleep(1); this.Location = new Point(this.Left + 10, this.Top); Thread.Sleep(1); this.Location = new Point(this.Left + 10, this.Top); Thread.Sleep(1); this.Location = new Point(this.Left, this.Top + 10); Thread.Sleep(1); this.Location = new Point(this.Left - 10, this.Top); MessageBox.Show("借用失败!失败原因:" + ex.Message.ToString(), "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information); } } else { MessageBox.Show("材料数量最多为" + c + ",请重新填写!", "提示"); numericUpDown1.Text = c.ToString(); } }
} else if (d == 0) { if (c >= num) { SqlCommand cmd1 = new SqlCommand("insert into RC(STNO,MSLNO,MSNO,BONU,BODA,RTDA) values ('" + login.id + "','" + labid + "','" + material + "','" + num + "','" + login.today + "','无需归还')", conn); try { conn.Open(); cmd1.ExecuteNonQuery(); int res = c - num; if (res == 0) { SqlCommand cmd2 = new SqlCommand("delete from MS where MSNO = '" + material + "' AND MSLNO = '" + labid + "'", conn); try { cmd2.ExecuteNonQuery(); MessageBox.Show("该材料不需要归还,借用成功!"); } catch (Exception ex) { this.Location = new Point(this.Left + 10, this.Top); Thread.Sleep(1); this.Location = new Point(this.Left, this.Top + 10); Thread.Sleep(1); this.Location = new Point(this.Left - 10, this.Top); Thread.Sleep(1); this.Location = new Point(this.Left - 10, this.Top); Thread.Sleep(1); this.Location = new Point(this.Left, this.Top - 10); Thread.Sleep(1); this.Location = new Point(this.Left, this.Top - 10); Thread.Sleep(1); this.Location = new Point(this.Left + 10, this.Top); Thread.Sleep(1); this.Location = new Point(this.Left + 10, this.Top); Thread.Sleep(1); this.Location = new Point(this.Left, this.Top + 10); Thread.Sleep(1); this.Location = new Point(this.Left - 10, this.Top); MessageBox.Show("删除原数据失败!失败原因:" + ex.Message.ToString(), "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information); } } else { SqlCommand cmd2 = new SqlCommand("update MS set MSNU = '" + res + "'where MSNO = '" + material + "' AND MSLNO = '" + labid + "'", conn); try { cmd2.ExecuteNonQuery(); MessageBox.Show("该材料不需要归还,借用成功!"); this.Hide(); student form1 = new student(); form1.Show(); } catch (Exception ex) { this.Location = new Point(this.Left + 10, this.Top); Thread.Sleep(1); this.Location = new Point(this.Left, this.Top + 10); Thread.Sleep(1); this.Location = new Point(this.Left - 10, this.Top); Thread.Sleep(1); this.Location = new Point(this.Left - 10, this.Top); Thread.Sleep(1); this.Location = new Point(this.Left, this.Top - 10); Thread.Sleep(1); this.Location = new Point(this.Left, this.Top - 10); Thread.Sleep(1); this.Location = new Point(this.Left + 10, this.Top); Thread.Sleep(1); this.Location = new Point(this.Left + 10, this.Top); Thread.Sleep(1); this.Location = new Point(this.Left, this.Top + 10); Thread.Sleep(1); this.Location = new Point(this.Left - 10, this.Top); MessageBox.Show("删除原数据失败!失败原因:" + ex.Message.ToString(), "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information); } } conn.Close(); conn.Close(); } catch (Exception ex) { MessageBox.Show("借用失败!失败原因:" + ex.Message.ToString(), "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information); } } else { this.Location = new Point(this.Left + 10, this.Top); Thread.Sleep(1); this.Location = new Point(this.Left, this.Top + 10); Thread.Sleep(1); this.Location = new Point(this.Left - 10, this.Top); Thread.Sleep(1); this.Location = new Point(this.Left - 10, this.Top); Thread.Sleep(1); this.Location = new Point(this.Left, this.Top - 10); Thread.Sleep(1); this.Location = new Point(this.Left, this.Top - 10); Thread.Sleep(1); this.Location = new Point(this.Left + 10, this.Top); Thread.Sleep(1); this.Location = new Point(this.Left + 10, this.Top); Thread.Sleep(1); this.Location = new Point(this.Left, this.Top + 10); Thread.Sleep(1); this.Location = new Point(this.Left - 10, this.Top); MessageBox.Show("材料数量最多为" + c + ",请重新填写!", "提示"); numericUpDown1.Text = c.ToString(); } } else { this.Location = new Point(this.Left + 10, this.Top); Thread.Sleep(1); this.Location = new Point(this.Left, this.Top + 10); Thread.Sleep(1); this.Location = new Point(this.Left - 10, this.Top); Thread.Sleep(1); this.Location = new Point(this.Left - 10, this.Top); Thread.Sleep(1); this.Location = new Point(this.Left, this.Top - 10); Thread.Sleep(1); this.Location = new Point(this.Left, this.Top - 10); Thread.Sleep(1); this.Location = new Point(this.Left + 10, this.Top); Thread.Sleep(1); this.Location = new Point(this.Left + 10, this.Top); Thread.Sleep(1); this.Location = new Point(this.Left, this.Top + 10); Thread.Sleep(1); this.Location = new Point(this.Left - 10, this.Top); MessageBox.Show("数据库信息错误,请联系管理员!"); } }
} }
private void tabPage5_Click(object sender, EventArgs e) {
}
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e) { comboBox2.DataSource = null; comboBox2.SelectedIndex = -1; comboBox2.Items.Clear(); SqlConnection conn = new(login.connectket); conn.Open(); DataSet ds1 = new DataSet(); SqlDataAdapter da = new SqlDataAdapter("select distinct MSNO from MS WHERE MSLNO = '" + comboBox1.Text + "'", conn); da.Fill(ds1); comboBox2.DataSource = ds1.Tables[0].DefaultView; comboBox2.DisplayMember = "MSNO"; conn.Close(); comboBox2.SelectedIndex = -1; }
private void numericUpDown1_ValueChanged(object sender, EventArgs e) {
}
private void button10_Click(object sender, EventArgs e) { SqlConnection conn = new(login.connectket); if (comboBox2.Text.Trim() == "") { MessageBox.Show("请选择材料!", "提示"); } else { string labid = comboBox1.Text.Trim(); string material = comboBox2.Text.Trim(); SqlCommand cmd5 = new SqlCommand("select MSDP from MS where MSNO = '" + material + "' AND MSLNO = '" + labid + "'", conn); conn.Open(); int d = Convert.ToInt32(cmd5.ExecuteScalar().ToString()); conn.Close(); if (d == 1) { MessageBox.Show("材料" + comboBox2.Text.Trim() + "需要归还!", "提示"); } else { MessageBox.Show("材料" + comboBox2.Text.Trim() + "不需要归还!", "提示"); } } }
private void comboBox2_SelectedIndexChanged(object sender, EventArgs e) {
}
private void comboBox3_SelectedIndexChanged(object sender, EventArgs e) { comboBox4.DataSource = null; comboBox4.SelectedIndex = -1; comboBox4.Items.Clear(); SqlConnection conn = new(login.connectket); conn.Open(); DataSet ds1 = new DataSet(); SqlDataAdapter da = new SqlDataAdapter("select distinct MSNO from BO WHERE MSLNO = '" + comboBox3.Text + "'", conn); da.Fill(ds1); comboBox4.DataSource = ds1.Tables[0].DefaultView; comboBox4.DisplayMember = "MSNO"; conn.Close(); comboBox4.SelectedIndex = -1; }
private void button11_Click(object sender, EventArgs e) { SqlConnection conn = new(login.connectket); if (comboBox3.Text.Trim() == "") { this.Location = new Point(this.Left + 10, this.Top); Thread.Sleep(1); this.Location = new Point(this.Left, this.Top + 10); Thread.Sleep(1); this.Location = new Point(this.Left - 10, this.Top); Thread.Sleep(1); this.Location = new Point(this.Left - 10, this.Top); Thread.Sleep(1); this.Location = new Point(this.Left, this.Top - 10); Thread.Sleep(1); this.Location = new Point(this.Left, this.Top - 10); Thread.Sleep(1); this.Location = new Point(this.Left + 10, this.Top); Thread.Sleep(1); this.Location = new Point(this.Left + 10, this.Top); Thread.Sleep(1); this.Location = new Point(this.Left, this.Top + 10); Thread.Sleep(1); this.Location = new Point(this.Left - 10, this.Top); MessageBox.Show("实验室编号为空!", "提示"); } else { if (comboBox4.Text.Trim() == "") { this.Location = new Point(this.Left + 10, this.Top); Thread.Sleep(1); this.Location = new Point(this.Left, this.Top + 10); Thread.Sleep(1); this.Location = new Point(this.Left - 10, this.Top); Thread.Sleep(1); this.Location = new Point(this.Left - 10, this.Top); Thread.Sleep(1); this.Location = new Point(this.Left, this.Top - 10); Thread.Sleep(1); this.Location = new Point(this.Left, this.Top - 10); Thread.Sleep(1); this.Location = new Point(this.Left + 10, this.Top); Thread.Sleep(1); this.Location = new Point(this.Left + 10, this.Top); Thread.Sleep(1); this.Location = new Point(this.Left, this.Top + 10); Thread.Sleep(1); this.Location = new Point(this.Left - 10, this.Top); MessageBox.Show("材料编号为空!", "提示"); } else { string labid = comboBox3.Text.Trim(); string material = comboBox4.Text.Trim(); int num = Convert.ToInt32(numericUpDown2.Value.ToString().Trim());
SqlCommand cmd4 = new SqlCommand("select BONU from BO where MSNO = '" + material + "' AND MSLNO = '" + labid + "' AND STNO = '" + login.id + "'", conn); SqlCommand cmd5 = new SqlCommand("select BODA from BO where MSNO = '" + material + "' AND MSLNO = '" + labid + "' AND STNO = '" + login.id + "'", conn); SqlCommand cmd6 = new SqlCommand("select MSNU from MS where MSNO = '" + material + "' AND MSLNO = '" + labid + "'", conn); SqlCommand cmd9 = new SqlCommand("select count(*) from MS where MSNO = '" + material + "' AND MSLNO = '" + labid + "'", conn); SqlCommand cmd11 = new SqlCommand("select CODE from BO where MSNO = '" + material + "' AND MSLNO = '" + labid + "' AND STNO = '" + login.id + "'", conn); conn.Open(); int orinum; int b = (int)cmd9.ExecuteScalar(); string code = cmd11.ExecuteScalar().ToString(); SqlDataReader dr = cmd5.ExecuteReader(); dr.Read(); string borrday = dr[0].ToString().Trim(); dr.Dispose(); cmd5.Dispose(); int c = (int)cmd4.ExecuteScalar(); if (b == 0) { orinum = 0; } else { SqlDataReader dr1 = cmd6.ExecuteReader(); dr1.Read(); orinum = Convert.ToInt32(dr1[0].ToString()); dr1.Dispose(); } conn.Close(); if (orinum > 0) { if (c >= num) { conn.Open(); int res = c - num; if (res == 0) { int x = orinum + num; SqlCommand cmd2 = new SqlCommand("delete from BO where MSNO = '" + material + "' AND MSLNO = '" + labid + "' AND BONU = '" + num + "' AND STNO = '" + login.id + "'AND CODE = '" + code + "'", conn); SqlCommand cmd3 = new SqlCommand("update RC set RTDA ='" + login.today + "'where MSNO = '" + material + "' AND MSLNO = '" + labid + "' AND BONU = '" + num + "' AND STNO = '" + login.id + "'", conn); SqlCommand cmd7 = new SqlCommand("update MS set MSNU = '" + x + "'where MSNO = '" + material + "' AND MSLNO = '" + labid + "'", conn); try { cmd2.ExecuteNonQuery(); cmd3.ExecuteNonQuery(); cmd7.ExecuteNonQuery(); MessageBox.Show("材料归还成功!"); } catch (Exception ex) { this.Location = new Point(this.Left + 10, this.Top); Thread.Sleep(1); this.Location = new Point(this.Left, this.Top + 10); Thread.Sleep(1); this.Location = new Point(this.Left - 10, this.Top); Thread.Sleep(1); this.Location = new Point(this.Left - 10, this.Top); Thread.Sleep(1); this.Location = new Point(this.Left, this.Top - 10); Thread.Sleep(1); this.Location = new Point(this.Left, this.Top - 10); Thread.Sleep(1); this.Location = new Point(this.Left + 10, this.Top); Thread.Sleep(1); this.Location = new Point(this.Left + 10, this.Top); Thread.Sleep(1); this.Location = new Point(this.Left, this.Top + 10); Thread.Sleep(1); this.Location = new Point(this.Left - 10, this.Top); MessageBox.Show("操作失败!失败原因:" + ex.Message.ToString(), "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information); } } else { int x = orinum + num; SqlCommand cmd2 = new SqlCommand("update BO set BONU = '" + res + "'where STNO = '" + login.id + "' AND MSLNO = '" + labid + "' AND BODA = '" + borrday + "' AND STNO = '" + login.id + "'AND CODE = '" + code + "'", conn); SqlCommand cmd7 = new SqlCommand("update MS set MSNU = '" + x + "'where MSNO = '" + material + "' AND MSLNO = '" + labid + "'", conn); try { cmd2.ExecuteNonQuery(); cmd7.ExecuteNonQuery(); MessageBox.Show("部分材料归还成功!"); this.Hide(); student form1 = new student(); form1.Show(); } catch (Exception ex) { this.Location = new Point(this.Left + 10, this.Top); Thread.Sleep(1); this.Location = new Point(this.Left, this.Top + 10); Thread.Sleep(1); this.Location = new Point(this.Left - 10, this.Top); Thread.Sleep(1); this.Location = new Point(this.Left - 10, this.Top); Thread.Sleep(1); this.Location = new Point(this.Left, this.Top - 10); Thread.Sleep(1); this.Location = new Point(this.Left, this.Top - 10); Thread.Sleep(1); this.Location = new Point(this.Left + 10, this.Top); Thread.Sleep(1); this.Location = new Point(this.Left + 10, this.Top); Thread.Sleep(1); this.Location = new Point(this.Left, this.Top + 10); Thread.Sleep(1); this.Location = new Point(this.Left - 10, this.Top); MessageBox.Show("操作失败!失败原因:" + ex.Message.ToString(), "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information); } } conn.Close(); } else { this.Location = new Point(this.Left + 10, this.Top); Thread.Sleep(1); this.Location = new Point(this.Left, this.Top + 10); Thread.Sleep(1); this.Location = new Point(this.Left - 10, this.Top); Thread.Sleep(1); this.Location = new Point(this.Left - 10, this.Top); Thread.Sleep(1); this.Location = new Point(this.Left, this.Top - 10); Thread.Sleep(1); this.Location = new Point(this.Left, this.Top - 10); Thread.Sleep(1); this.Location = new Point(this.Left + 10, this.Top); Thread.Sleep(1); this.Location = new Point(this.Left + 10, this.Top); Thread.Sleep(1); this.Location = new Point(this.Left, this.Top + 10); Thread.Sleep(1); this.Location = new Point(this.Left - 10, this.Top); MessageBox.Show("材料数量最多为" + c + ",请重新填写!", "提示"); numericUpDown2.Text = c.ToString(); } } else { if (c >= num) { conn.Open(); int res = c - num; if (res == 0) { int x = orinum + num; SqlCommand cmd2 = new SqlCommand("delete from BO where MSNO = '" + material + "' AND MSLNO = '" + labid + "' AND BONU = '" + num + "' AND STNO = '" + login.id + "'", conn); SqlCommand cmd3 = new SqlCommand("update RC set RTDA ='" + login.today + "'where MSNO = '" + material + "' AND MSLNO = '" + labid + "' AND BONU = '" + num + "' AND STNO = '" + login.id + "'", conn); SqlCommand cmd7 = new SqlCommand("insert into MS(MSNO,MSNU,MSLNO,MSDP) values ('" + material + "','" + x + "','" + labid + "','" + 1 + "')", conn); try { cmd2.ExecuteNonQuery(); cmd3.ExecuteNonQuery(); cmd7.ExecuteNonQuery(); MessageBox.Show("材料归还成功!"); } catch (Exception ex) { this.Location = new Point(this.Left + 10, this.Top); Thread.Sleep(1); this.Location = new Point(this.Left, this.Top + 10); Thread.Sleep(1); this.Location = new Point(this.Left - 10, this.Top); Thread.Sleep(1); this.Location = new Point(this.Left - 10, this.Top); Thread.Sleep(1); this.Location = new Point(this.Left, this.Top - 10); Thread.Sleep(1); this.Location = new Point(this.Left, this.Top - 10); Thread.Sleep(1); this.Location = new Point(this.Left + 10, this.Top); Thread.Sleep(1); this.Location = new Point(this.Left + 10, this.Top); Thread.Sleep(1); this.Location = new Point(this.Left, this.Top + 10); Thread.Sleep(1); this.Location = new Point(this.Left - 10, this.Top); MessageBox.Show("操作失败!失败原因:" + ex.Message.ToString(), "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information); } } else { int x = orinum + num; SqlCommand cmd2 = new SqlCommand("update BO set BONU = '" + res + "'where STNO = '" + login.id + "' AND MSLNO = '" + labid + "' AND BONU = '" + c + "' AND STNO = '" + login.id + "'", conn); SqlCommand cmd3 = new SqlCommand("insert into RC(STNO,MSLNO,MSNO,BONU,BODA,RTDA) values ('" + login.id + "','" + labid + "','" + material + "','" + num + "','" + borrday + "','" + login.today + "')", conn); SqlCommand cmd7 = new SqlCommand("insert into MS(MSNO,MSNU,MSLNO,MSDP) values ('" + material + "','" + x + "','" + labid + "','" + 1 + "')", conn); try { cmd2.ExecuteNonQuery(); cmd3.ExecuteNonQuery(); cmd7.ExecuteNonQuery(); MessageBox.Show("部分材料归还成功!"); this.Hide(); student form1 = new student(); form1.Show(); } catch (Exception ex) { this.Location = new Point(this.Left + 10, this.Top); Thread.Sleep(1); this.Location = new Point(this.Left, this.Top + 10); Thread.Sleep(1); this.Location = new Point(this.Left - 10, this.Top); Thread.Sleep(1); this.Location = new Point(this.Left - 10, this.Top); Thread.Sleep(1); this.Location = new Point(this.Left, this.Top - 10); Thread.Sleep(1); this.Location = new Point(this.Left, this.Top - 10); Thread.Sleep(1); this.Location = new Point(this.Left + 10, this.Top); Thread.Sleep(1); this.Location = new Point(this.Left + 10, this.Top); Thread.Sleep(1); this.Location = new Point(this.Left, this.Top + 10); Thread.Sleep(1); this.Location = new Point(this.Left - 10, this.Top); MessageBox.Show("操作失败!失败原因:" + ex.Message.ToString(), "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information); } } conn.Close(); } else { MessageBox.Show("材料数量最多为" + c + ",请重新填写!", "提示"); numericUpDown2.Text = c.ToString(); } } } } }
private void button12_Click(object sender, EventArgs e) { comboBox4.DataSource = null; comboBox3.SelectedIndex = -1; comboBox4.SelectedIndex = -1; this.numericUpDown2.DecimalPlaces = 0; this.numericUpDown2.Value = Decimal.Round(1, 0); returnday = ""; }
private void button13_Click(object sender, EventArgs e) { SqlConnection conn = new(login.connectket); SqlCommand cmd6 = new SqlCommand("select count(*) from BO where (" + Convert.ToInt32(login.today) + "-RTDA)>='" + 0 + "' AND STNO = '" + login.id + "'", conn); SqlDataAdapter adapter = new SqlDataAdapter(); adapter.SelectCommand = cmd6; int getw = (int)cmd6.ExecuteScalar(); if (MessageBox.Show("确认删除?", "提示信息", MessageBoxButtons.YesNo) == DialogResult.Yes) { if (MessageBox.Show("最后一次确认删除?", "提示信息", MessageBoxButtons.YesNo) == DialogResult.Yes) { if (getw > 0) { this.Location = new Point(this.Left + 10, this.Top); Thread.Sleep(1); this.Location = new Point(this.Left, this.Top + 10); Thread.Sleep(1); this.Location = new Point(this.Left - 10, this.Top); Thread.Sleep(1); this.Location = new Point(this.Left - 10, this.Top); Thread.Sleep(1); this.Location = new Point(this.Left, this.Top - 10); Thread.Sleep(1); this.Location = new Point(this.Left, this.Top - 10); Thread.Sleep(1); this.Location = new Point(this.Left + 10, this.Top); Thread.Sleep(1); this.Location = new Point(this.Left + 10, this.Top); Thread.Sleep(1); this.Location = new Point(this.Left, this.Top + 10); Thread.Sleep(1); this.Location = new Point(this.Left - 10, this.Top); MessageBox.Show("您有" + getw + "条已过期未还材料记录,请及时归还材料后进行注销操作!", "提示"); } else { SqlCommand cmd1 = new SqlCommand("delete from ST where STNO = '" + login.id + "'", conn); SqlCommand cmd2 = new SqlCommand("delete from BO where STNO = '" + login.id + "'", conn); cmd1.ExecuteNonQuery(); cmd2.ExecuteNonQuery(); MessageBox.Show("注销账户成功", "提示"); this.Hide(); login form1 = new login(); form1.Show(); } } } conn.Close(); }
private void label15_Click(object sender, EventArgs e) {
}
} }
|