示例#1
0
        private void BtnUpdClick(object sender, EventArgs e)
        {
            List <string> list = new List <string>();

            if (inf0.Text == string.Empty)
            {
                MessageBox.Show("请输入课程编号!");
                return;
            }
            if (inf1.Enabled)
            {
                if (inf1.Text == string.Empty)
                {
                    MessageBox.Show("请输入课程的完整信息!");
                    return;
                }
                list.Add($"cname='{inf1.Text}'");
            }
            if (inf2.Enabled)
            {
                if (inf2.Text == string.Empty)
                {
                    MessageBox.Show("请输入课程的完整信息!");
                    return;
                }
                list.Add($"tname='{inf2.Text}'");
            }
            if (inf3.Enabled)
            {
                if (inf3.Text == string.Empty)
                {
                    MessageBox.Show("请输入课程的完整信息!");
                    return;
                }
                list.Add($"credit={inf3.Text}");
            }
            if (inf4.Enabled)
            {
                if (inf4.Text == string.Empty)
                {
                    MessageBox.Show("请输入课程的完整信息!");
                    return;
                }
                list.Add($"grade={inf4.Text}");
            }
            if (inf5.Enabled)
            {
                list.Add($"cyear={(inf5.Text == string.Empty ? "null" : inf5.Text)}");
            }
            if (list.Count > 0)
            {
                string cmd = $"update courses set {string.Join(",", list.ToArray())} where cid='{inf0.Text}';";
                DBO.Update(cmd);
                MessageBox.Show("修改成功");
            }
        }
示例#2
0
        private void BtnUpdClick(object sender, EventArgs e)
        {
            List <string> list = new List <string>();

            if (inf0.Text == string.Empty)
            {
                MessageBox.Show("请输入学生学号!");
                return;
            }
            if (inf1.Text == string.Empty)
            {
                MessageBox.Show("请输入课程编号!");
                return;
            }
            if (inf2.Enabled)
            {
                if (inf2.Text == string.Empty)
                {
                    MessageBox.Show("请输入选课的完整信息!");
                    return;
                }
                list.Add($"ryear={inf2.Text}");
            }
            if (inf3.Enabled)
            {
                if (inf3.Text == string.Empty)
                {
                    MessageBox.Show("请输入选课的完整信息!");
                    return;
                }
                list.Add($"score={inf3.Text}");
            }
            if (list.Count > 0)
            {
                string cmd = $"update register set {string.Join(",", list.ToArray())} where sid='{inf0.Text}' and cid='{inf1.Text}';";
                DBO.Update(cmd);
                MessageBox.Show("修改成功!");
            }
        }
示例#3
0
        private void BtnUpdClick(object sender, EventArgs e)
        {
            List <string> list = new List <string>();

            if (inf0.Text == string.Empty)
            {
                MessageBox.Show("请输入学生学号!");
                return;
            }
            if (inf1.Enabled)
            {
                if (inf1.Text == string.Empty)
                {
                    MessageBox.Show("请输入学生的完整信息!");
                    return;
                }
                list.Add($"sname='{inf1.Text}'");
            }
            if (inf2.Enabled)
            {
                if (inf2.Text == string.Empty)
                {
                    MessageBox.Show("请输入学生的完整信息!");
                    return;
                }
                list.Add($"gender='{inf2.SelectedItem}'");
            }
            if (inf3.Enabled)
            {
                if (inf3.Text == string.Empty)
                {
                    MessageBox.Show("请输入学生的完整信息!");
                    return;
                }
                if (!int.TryParse(inf3.Text, out int age) || age < 10 || age > 50)
                {
                    MessageBox.Show("学生年龄无效,请重新输入!");
                    inf3.Text = string.Empty;
                    return;
                }
                list.Add($"enage={inf3.Text}");
            }
            if (inf4.Enabled)
            {
                if (inf4.Text == string.Empty)
                {
                    MessageBox.Show("请输入学生的完整信息!");
                    return;
                }
                list.Add($"grade={inf4.Text}");
            }
            if (inf5.Enabled)
            {
                if (inf5.Text == string.Empty)
                {
                    MessageBox.Show("请输入学生的完整信息!");
                    return;
                }
                list.Add($"class='{inf5.Text}'");
            }
            if (list.Count > 0)
            {
                string cmd = $"update students set {string.Join(",", list.ToArray())} where sid='{inf0.Text}';";
                DBO.Update(cmd);
                MessageBox.Show("修改成功");
            }
        }