增加型号.cs

来自「湖南岳阳电力部门 电力管理系统 .net C#开发的」· CS 代码 · 共 62 行

CS
62
字号
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace 计量
{
    public partial class 增加型号 : Form
    {
        public 增加型号()
        {
            InitializeComponent();
        }

        private void 增加型号_Load(object sender, EventArgs e)
        {
            // TODO: 这行代码将数据加载到表“sqldatabase_DataDataSet.型号表”中。您可以根据需要移动或移除它。
           
            this.textBox1.ReadOnly = true;
            this.textBox1.Text = getid();
        }
        private string getid()
        {
            string idtype = "XID1";

            try
            {
                DataTable dt = this.型号表TableAdapter.GetData();
                DataRow[] dr = dt.Select("", "型号ID asc");
                if (dr.Length != 0)
                {
                    idtype = dr[dr.Length - 1].ItemArray[0].ToString().Trim();
                    idtype = "XID" + (int.Parse(idtype.Substring(3, idtype.Length - 3)) + 1);
                    return idtype;
                }
            }
            catch (Exception exc)
            {
                MessageBox.Show(exc.Message);
            }
            return idtype;
        }

        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                int ii = this.型号表TableAdapter.Insert(this.textBox1.Text.Trim(),this.textBox2.Text.Trim(),this.textBox3.Text.Trim(),this.textBox4.Text.Trim(),this.textBox5.Text.Trim());
                if (ii == 0) MessageBox.Show("增加失败");
                else MessageBox.Show("增加成功");
            }
            catch (Exception exc)
            {
                MessageBox.Show("增加失败"+exc.Message);
            }
            this.Close();
        } 
    }
}

⌨️ 快捷键说明

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