protected void Butsave_Click(object sender, EventArgs e) { if (email.Text == "" || paswd.Text == "") { ListMsg.Text = "please fill mandatory fields"; } else if (paswd.Text != confirm.Text) { ListMsg.Text = "Password did not match"; } else if (UploadImgSave.PostedFile != null) { string imgFile = Path.GetFileName(UploadImgSave.PostedFile.FileName); UploadImgSave.SaveAs(@"E:\Semester 6\EAD\Practical_Work\StoreManagementSystem\StoreManagementSystem\Images/" + imgFile); SqlConnection connection = new SqlConnection(con); string queryString = "INSERT INTO [dbo].[User] ([name],[Pasword],[Email],[image]) VALUES (@name,@Pasword,@Email,@image)"; SqlCommand cmd = new SqlCommand(queryString, connection); connection.Open(); cmd.Parameters.AddWithValue("@name", name.Text); cmd.Parameters.AddWithValue("@Email", email.Text); cmd.Parameters.AddWithValue("@Pasword", paswd.Text); cmd.Parameters.AddWithValue("@image", "Image/" + imgFile); cmd.ExecuteNonQuery(); ListMsg.Text = "Registered successsfully"; connection.Close(); Response.Redirect("Login.aspx"); } else { ListMsg.Text = " not registered "; } }
protected void saveBtn_Click(object sender, EventArgs e) { if (UploadImgSave.PostedFile != null) { string imgFile = Path.GetFileName(UploadImgSave.PostedFile.FileName); UploadImgSave.SaveAs(@"E:\Semester 6\EAD\Practical_Work\StoreManagementSystem\StoreManagementSystem\Images/" + imgFile); SqlConnection connection = new SqlConnection(con); connection.Open(); string query = "INSERT INTO [dbo].[Product] ([name],[price],[image]) VALUES (@name,@price,@image)"; SqlCommand cmd = new SqlCommand(query, connection); cmd.Parameters.AddWithValue("@name", id.Text); cmd.Parameters.AddWithValue("@price", price.Text); cmd.Parameters.AddWithValue("@image", "Images/" + imgFile); cmd.ExecuteNonQuery(); ListMsg.Text = "Image and its path saved successsfully"; connection.Close(); } else { ListMsg.Text = "Image and its path failed saved "; } }