Ejemplo n.º 1
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            if (btnSave.Text == "Save")
            {
                string query = @"DECLARE @dbccVal INT = (SELECT COUNT(*) FROM AppUser)
	IF (@dbccVal != 0) SET @dbccVal = (SELECT TOP 1 Id FROM AppUser ORDER BY Id DESC)
    Else SET @dbccVal =1
	DBCC CHECKIDENT('AppUser', RESEED, @dbccVal)
insert into AppUser ( UserName,Password,TypeName,ComFlag,UpdateCardBy,UpdateCardDate) VALUES ('" + txtUserName.Text + "','" + txtPassword.Text + "','Admin','','" + HttpContext.Current.User.Identity.Name + "',getdate())";
                if (u.CommonSqlExecutionBool(query))
                {
                    Show("Data inserted successfully");
                    loadRepeater();
                    btnCancelNew_Click(null, null);
                }
            }
            if (btnSave.Text == "Update")
            {
                string query = "Update AppUser set UserName='******',Password='******',UpdateCardBy='" + HttpContext.Current.User.Identity.Name + "',UpdateCardDate=getdate() where Id='" + ViewState["Id"] + "'";
                if (u.CommonSqlExecutionBool(query))
                {
                    Show("Data Update successfully");
                    loadRepeater();
                    btnCancelNew_Click(null, null);
                }
            }
        }