예제 #1
0
        public void LoadCategory()
        {
            try
            {
                DataTable dt;

                catObj.MainCatID = Convert.ToInt16(CboMainCat.SelectedValue.ToString());
                dt = catObj.GetCategoryByMaincat(catObj);

                if (dt.Rows.Count > 0)
                {
                    CboCategory.DataSource     = dt;
                    CboCategory.DataTextField  = "Category";
                    CboCategory.DataValueField = "CatID";
                    CboCategory.DataBind();
                }
                else
                {
                    CboCategory.DataSource     = dt;
                    CboCategory.DataTextField  = "Category";
                    CboCategory.DataValueField = "CatID";
                    CboCategory.DataBind();
                }
            }
            catch (Exception ex)
            {
                LblMessage.Text = ex.Message.ToString();
            }
        }
        void LoadCategories(string categoryName = "")
        {
            ApiResponse response = Helper.GetCategories(categoryName);

            try
            {
                if (response.responseCode == ApiResponse.Success)
                {
                    InventoryUi.Models.Category[] data = JsonConvert.DeserializeObject <InventoryUi.Models.Category[]>(response.data.ToString());
                    using (DataTable dt = Helper.CreateDataTable(data, ""))
                    {
                        CboCategory.DataSource     = dt;
                        CboCategory.DataTextField  = "CategoryName";
                        CboCategory.DataValueField = "CategoryId";
                        CboCategory.DataBind();
                    }
                }
                else if (response.responseCode == ApiResponse.NoDataFound)
                {
                    TxtDescription.Text = string.Empty;
                    LblErrorMsg.Text    = "No Data Found";
                    LblErrorMsg.Visible = true;
                }
                else if (response.responseCode == ApiResponse.Exception)
                {
                    TxtDescription.Text = string.Empty;
                    LblErrorMsg.Text    = "Api Error: " + response.error;
                    LblErrorMsg.Visible = true;
                }
            }
            catch (Exception ex)
            {
                TxtDescription.Text = string.Empty;
                LblErrorMsg.Text    = "Page Error: " + ex.Message;
                LblErrorMsg.Visible = true;
            }
        }