protected void Page_Load(object sender, EventArgs e)
        {
            string   jsonResult = string.Empty;
            DALClass dalClass   = new DALClass();

            try
            {
                string    strProductNo = Request["strProductNo"];
                DataTable dtProduct    = dalClass.GetProductByNo(strProductNo);
                if (dtProduct != null && dtProduct.Rows.Count > 0)
                {
                    string strProductName  = string.Empty;
                    string strProductColor = string.Empty;
                    string strProductSize  = string.Empty;
                    string strProductPrice = string.Empty;
                    string strProductId    = string.Empty;
                    if (!(dtProduct.Rows[0]["ProductName"] is DBNull))
                    {
                        strProductName = dtProduct.Rows[0]["ProductName"].ToString();
                    }
                    if (!(dtProduct.Rows[0]["ProductColor"] is DBNull))
                    {
                        strProductColor = dtProduct.Rows[0]["ProductColor"].ToString();
                    }
                    if (!(dtProduct.Rows[0]["ProductSize"] is DBNull))
                    {
                        strProductSize = dtProduct.Rows[0]["ProductSize"].ToString();
                    }
                    if (!(dtProduct.Rows[0]["ProductPrice"] is DBNull))
                    {
                        strProductPrice = dtProduct.Rows[0]["ProductPrice"].ToString();
                    }
                    if (!(dtProduct.Rows[0]["ProductId"] is DBNull))
                    {
                        strProductId = dtProduct.Rows[0]["ProductId"].ToString();
                    }
                    jsonResult = "{\"Product\":" +
                                 "[" +
                                 "{\"ProductName\":\"" + strProductName + "\",\"ProductColor\":\"" + strProductColor + "\"," +
                                 "\"ProductSize\":\"" + strProductSize + "\"," + "\"ProductPrice\":\"" + strProductPrice + "\"," +
                                 "\"ProductId\":\"" + strProductId + "\"}" +
                                 "]" +
                                 "}";
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }

            Response.Write(jsonResult);
            Response.End();
        }
        /// <summary>
        ///  Binds the data of the salesman to DropDownList control.
        /// </summary>
        private void BindSalesman()
        {
            dpd_SalesMan.Items.Clear();
            DALClass  dalClass   = new DALClass();
            DataTable dtSalesMan = dalClass.GetSalesMan();

            if (dtSalesMan != null && dtSalesMan.Rows.Count > 0)
            {
                dpd_SalesMan.DataSource     = dtSalesMan;
                dpd_SalesMan.DataValueField = "SalesManId";
                dpd_SalesMan.DataTextField  = "SalesManName";
                dpd_SalesMan.DataBind();
            }
        }
Пример #3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string   jsonResult = string.Empty;
            DALClass dalClass   = new DALClass();

            try
            {
                string    strCustomerName = Request["strCustomerName"];
                DataTable dtCustomer      = dalClass.GetCustomerByName(strCustomerName);
                if (dtCustomer != null && dtCustomer.Rows.Count > 0)
                {
                    string strAddress   = string.Empty;
                    string strTelePhone = string.Empty;

                    if (!(dtCustomer.Rows[0]["CustomerAddress"] is DBNull))
                    {
                        strAddress = dtCustomer.Rows[0]["CustomerAddress"].ToString();
                    }

                    if (!(dtCustomer.Rows[0]["CustomerTelePhone"] is DBNull))
                    {
                        strTelePhone = dtCustomer.Rows[0]["CustomerTelePhone"].ToString();
                    }
                    jsonResult = "{\"Customer\":" +
                                 "[" +
                                 "{\"Address\":\"" + strAddress + "\",\"TelePhone\":\"" + strTelePhone + "\"}" +
                                 "]" +
                                 "}";
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }

            Response.Write(jsonResult);
            Response.End();
        }