Esempio n. 1
0
        private void button1_Click(object sender, EventArgs e)
        {
            string aa = DTP.Value.ToString("yyyy-MM-dd HH:mm:ss");

            Maticsoft.BLL.username   use = new Maticsoft.BLL.username();
            Maticsoft.Model.username us  = new username()
            {
                user     = txt_n.Text,
                addtime  = Convert.ToDateTime(aa),
                password = txt_p.Text,
                power    = txt_q.Text,
            };
            use.Add(us);
            MessageBox.Show("保存成功");
            this.Close();
        }
Esempio n. 2
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            string strErr = "";

            if (this.txtusername.Text.Trim().Length == 0)
            {
                strErr += "username不能为空!\\n";
            }
            if (!PageValidate.IsDateTime(txtaddtime.Text))
            {
                strErr += "addtime格式错误!\\n";
            }
            if (this.txtpassword.Text.Trim().Length == 0)
            {
                strErr += "password不能为空!\\n";
            }
            if (this.txtpower.Text.Trim().Length == 0)
            {
                strErr += "power不能为空!\\n";
            }

            if (strErr != "")
            {
                MessageBox.Show(this, strErr);
                return;
            }
            string   username = this.txtusername.Text;
            DateTime addtime  = DateTime.Parse(this.txtaddtime.Text);
            string   password = this.txtpassword.Text;
            string   power    = this.txtpower.Text;

            Maticsoft.Model.username model = new Maticsoft.Model.username();
            model.username = username;
            model.addtime  = addtime;
            model.password = password;
            model.power    = power;

            Maticsoft.BLL.username bll = new Maticsoft.BLL.username();
            bll.Add(model);
            Maticsoft.Common.MessageBox.ShowAndRedirect(this, "保存成功!", "add.aspx");
        }