public CustomerWiseProductENT SelectByPK(SqlInt32 CustomerWiseProductID) { using (SqlConnection objConnection = new SqlConnection(ConnectionString)) { using (SqlCommand objcmd = objConnection.CreateCommand()) { try { objConnection.Open(); #region Prepare Command objcmd.CommandType = CommandType.StoredProcedure; objcmd.CommandText = "PR_CustomerWiseProduct_SelectByPK"; objcmd.Parameters.AddWithValue("@CustomerWiseProductID", CustomerWiseProductID.ToString()); #endregion Prepare Command #region ReadData And SetData CustomerWiseProductENT entCustomerWiseProduct = new CustomerWiseProductENT(); using (SqlDataReader objSDR = objcmd.ExecuteReader()) { while (objSDR.Read()) { if (!objSDR["CustomerID"].Equals(DBNull.Value)) { entCustomerWiseProduct.CustomerID = Convert.ToInt32(objSDR["CustomerID"]); } if (!objSDR["ProductID"].Equals(DBNull.Value)) { entCustomerWiseProduct.ProductID = Convert.ToInt32(objSDR["ProductID"]); } } } return(entCustomerWiseProduct); #endregion ReadData And SetData } catch (SqlException Sqlex) { Message = Sqlex.Message.ToString(); return(null); } catch (Exception ex) { Message = ex.Message.ToString(); return(null); } finally { if (objConnection.State == ConnectionState.Open) { objConnection.Close(); } } } } }
public Boolean Update(CustomerWiseProductENT entCustomerWiseProduct) { CustomerWiseProductDAL CustomerWiseProductDAL = new CustomerWiseProductDAL(); if (CustomerWiseProductDAL.Update(entCustomerWiseProduct)) { return(true); } else { this.Message = CustomerWiseProductDAL.Message; return(false); } }
private void LoadControls(SqlInt32 CustomerWiseProductID) { CustomerWiseProductENT entCustomerWiseProduct = new CustomerWiseProductENT(); CustomerWiseProductBAL balCustomerWiseProduct = new CustomerWiseProductBAL(); entCustomerWiseProduct = balCustomerWiseProduct.SelectByPK(CustomerWiseProductID); if (!entCustomerWiseProduct.CustomerID.IsNull) { ddlCustomer.SelectedValue = entCustomerWiseProduct.CustomerID.Value.ToString(); } if (!entCustomerWiseProduct.ProductID.IsNull) { ddlProduct.SelectedValue = entCustomerWiseProduct.ProductID.Value.ToString(); } }
public Boolean Update(CustomerWiseProductENT entCustomerWiseProduct) { using (SqlConnection objConnection = new SqlConnection(ConnectionString)) { using (SqlCommand objcmd = objConnection.CreateCommand()) { try { objConnection.Open(); #region Prepare Command objcmd.CommandType = CommandType.StoredProcedure; objcmd.CommandText = "PR_CustomerWiseProduct_UpdateByPK"; objcmd.Parameters.AddWithValue("@CustomerWiseProductID", entCustomerWiseProduct.CustomerWiseProductID); objcmd.Parameters.AddWithValue("@CustomerID", entCustomerWiseProduct.CustomerID); objcmd.Parameters.AddWithValue("@ProductID", entCustomerWiseProduct.ProductID); objcmd.Parameters.AddWithValue("@UserID", entCustomerWiseProduct.UserID); #endregion Prepare Command #region ReadData And SetData objcmd.ExecuteNonQuery(); return(true); #endregion ReadData And SetData } catch (SqlException Sqlex) { Message = Sqlex.Message.ToString(); return(false); } catch (Exception ex) { Message = ex.Message.ToString(); return(false); } finally { if (objConnection.State == ConnectionState.Open) { objConnection.Close(); } } } } }
protected void btnSave_Click(object sender, EventArgs e) { #region ServerSide Validation #endregion ServerSide Validations CustomerWiseProductENT entCustomerWiseProduct = new CustomerWiseProductENT(); CustomerWiseProductBAL balCustomerWiseProduct = new CustomerWiseProductBAL(); #region Gather Data if (ddlCustomer.SelectedIndex > 0) { entCustomerWiseProduct.CustomerID = Convert.ToInt32(ddlCustomer.SelectedValue); } if (ddlProduct.SelectedIndex > 0) { entCustomerWiseProduct.ProductID = Convert.ToInt32(ddlProduct.SelectedValue); } entCustomerWiseProduct.CreationDate = DateTime.Now; entCustomerWiseProduct.UserID = Convert.ToInt32(Session["UserID"]); if (Request.QueryString["CustomerWiseProductID"] == null) { balCustomerWiseProduct.Insert(entCustomerWiseProduct); lblMessage.Text = "Data Insert SuccessFully"; ClearControl(); } else { entCustomerWiseProduct.CustomerWiseProductID = Convert.ToInt32(Request.QueryString["CustomerWiseProductID"]); balCustomerWiseProduct.Update(entCustomerWiseProduct); Response.Redirect("~/AdminPanel/CustomerWiseProduct/CustomerWiseProductList.aspx"); } #endregion Gather Data }