public ELCustomer SelectCustomer(ELCustomer eLCustomer, string connectionString) { ELCustomer objCustomer = new ELCustomer(); using (SqlConnection conn = new SqlConnection()) { conn.ConnectionString = connectionString; conn.Open(); SqlCommand cmd = new SqlCommand("EXEC SelectCustomer @CustomerId", conn); cmd.Parameters.Add(new SqlParameter("CustomerId", eLCustomer.Id)); using (SqlDataReader reader = cmd.ExecuteReader()) { while (reader.Read()) { objCustomer.Id = Guid.Parse(reader[0].ToString()); objCustomer.Name = (reader[1].ToString()); objCustomer.projectId = Guid.Parse(reader[2].ToString()); objCustomer.Creator = Guid.Parse(reader[3].ToString()); objCustomer.CreatedAt = DateTime.Parse(reader[4].ToString()); objCustomer.Modifier = Guid.Parse(reader[5].ToString()); objCustomer.ModifiedAt = DateTime.Parse(reader[6].ToString()); } } } return(objCustomer); }
public List <ELCustomer> SelectAllCustomer(string connectionString) { List <ELCustomer> customerList = new List <ELCustomer>(); using (SqlConnection conn = new SqlConnection()) { conn.ConnectionString = connectionString; conn.Open(); SqlCommand cmd = new SqlCommand("EXEC SelectAllCustomer", conn); using (SqlDataReader reader = cmd.ExecuteReader()) { while (reader.Read()) { ELCustomer objCustomer = new ELCustomer(); objCustomer.Id = Guid.Parse(reader[0].ToString()); objCustomer.Name = (reader[1].ToString()); objCustomer.projectId = Guid.Parse(reader[2].ToString()); objCustomer.Creator = Guid.Parse(reader[3].ToString()); objCustomer.CreatedAt = DateTime.Parse(reader[4].ToString()); objCustomer.Modifier = Guid.Parse(reader[5].ToString()); objCustomer.ModifiedAt = DateTime.Parse(reader[6].ToString()); customerList.Add(objCustomer); } } } return(customerList); }
public void DeleteCustomer(ELCustomer eLCustomer, string connectionString) { using (SqlConnection conn = new SqlConnection()) { conn.ConnectionString = connectionString; conn.Open(); SqlCommand cmd = new SqlCommand("EXEC DeleteCustomer @CustomerId", conn); cmd.Parameters.Add(new SqlParameter("CustomerId", eLCustomer.Id)); cmd.ExecuteNonQuery(); } }
protected void CustomerUpdateButton_Click(object sender, EventArgs e) { ELCustomer ObjElCustomerUpdate = new ELCustomer(); ObjElCustomerUpdate.Id = Guid.Parse(CustomerId); // ObjElCustomerUpdate.objProject.Id = Guid.Parse(ProjectId.Text); ObjElCustomerUpdate.Name = IdCustomerName.Text; ObjElCustomerUpdate.Modifier = Guid.Parse(Session["UserId"].ToString()); ObjElCustomerUpdate.ModifiedAt = DateTime.Now; ObjDlCustomer.UpdateCustomer(ObjElCustomerUpdate, ObjConetion.connectionstring); //ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('Record Inserted Successfully')", true); ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert('Updated Successfully');Window.location ='CustomerViewPage.aspx';", true); }
public void UpdateCustomer(ELCustomer eLCustomer, string connectionString) { using (SqlConnection conn = new SqlConnection()) { conn.ConnectionString = connectionString; conn.Open(); SqlCommand cmd = new SqlCommand("EXEC UpdateCustomer @CustomerId,@Name,@ProjectId,@Modifier,@ModifiedAt", conn); cmd.Parameters.Add(new SqlParameter("CustomerId", eLCustomer.Id)); cmd.Parameters.Add(new SqlParameter("Name", eLCustomer.Name)); cmd.Parameters.Add(new SqlParameter("ProjectId", eLCustomer.projectId)); cmd.Parameters.Add(new SqlParameter("Modifier", eLCustomer.Modifier)); cmd.Parameters.Add(new SqlParameter("ModifiedAt", eLCustomer.ModifiedAt)); cmd.ExecuteNonQuery(); } }
protected void AddCustomerSubmit_Click(object sender, EventArgs e) { //DropDownListProjectName DLCustomer ObjDLCustomer = new DLCustomer(); ELCustomer ObjElCustomer = new ELCustomer(); ObjElCustomer.Name = TextBoxCustomerName.Text; ObjElCustomer.projectId = Guid.Parse(DropDownListProjectName.Text); ObjElCustomer.Creator = Id; ObjElCustomer.CreatedAt = DateTime.Now; ObjElCustomer.Modifier = ObjElCustomer.Creator; ObjElCustomer.ModifiedAt = ObjElCustomer.CreatedAt; ObjDLCustomer.AddCustomer(ObjElCustomer, ObjConetion.connectionstring); // ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert('Inserted Customer Successfully');Window.location ='CustomerViewPage.aspx';", true); ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert('Inserted Customer Successfully');window.location ='CustomerViewPage.aspx';", true); }
protected void GridViewCustomer_RowDeleting(object sender, GridViewDeleteEventArgs e) { Response.Write(GridViewCustomer.Rows[e.RowIndex].Cells[2].Text); var proId = GridViewCustomer.Rows[e.RowIndex].Cells[2].Text; ELCustomer ObjElProjectDelete = new ELCustomer(); ObjElProjectDelete.Id = Guid.Parse(proId); try { ObjDlCoustomer.DeleteCustomer(ObjElProjectDelete, ObjConetion.connectionstring); } catch (Exception) { ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert('You Cant Delete Customer because Its Refernce of Class')", true); } ViewCustomerData(); BindGridList(); }
protected void Page_Load(object sender, EventArgs e) { ELCustomer ObjElCustomer = new ELCustomer(); CustomerId = Request.QueryString["CustomerId"]; LabelCustomerId.Text = CustomerId; ObjElCustomer.Id = Guid.Parse(CustomerId); ObjElCustomer = ObjDlCustomer.SelectCustomer(ObjElCustomer, ObjConetion.connectionstring); if (!IsPostBack) { IdCustomerName.Text = ObjElCustomer.Name; } ProjectId.Text = ObjElCustomer.Id.ToString(); CustomerCreator.Text = ObjElCustomer.Creator.ToString(); CustomerCreatedAt.Text = ObjElCustomer.CreatedAt.ToString(); CustomerModifier.Text = ObjElCustomer.Modifier.ToString(); CustomerModifiedAt.Text = ObjElCustomer.ModifiedAt.ToString(); }