Ejemplo n.º 1
0
        /// <summary>
        /// This method get the list of Item Category .
        /// </summary>
        /// <returns>returns list of category.</returns>
        public List <IItemCategory> GetCategoryList()
        {
            SqlConnection        objSQLConn    = null;
            SqlCommand           objSQLCommand = null;
            List <IItemCategory> lstCategory   = new List <IItemCategory>();

            try
            {
                objSQLConn = new SqlConnection(strConnectionString);
                objSQLConn.Open();

                objSQLCommand             = new SqlCommand("usp_getitemcategory", objSQLConn);
                objSQLCommand.CommandType = System.Data.CommandType.StoredProcedure;

                SqlDataReader objSQLReader = objSQLCommand.ExecuteReader();

                while (objSQLReader.Read())
                {
                    IItemCategory objCategory = ItemCategotyBOFactory.CreateItemCategoryObject();
                    objCategory.CategoryId   = Convert.ToInt32(objSQLReader["CategoryID"]);
                    objCategory.CategoryName = Convert.ToString(objSQLReader["CategoryName"]);


                    lstCategory.Add(objCategory);
                }

                objSQLReader.Close();
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                if (objSQLConn != null && objSQLConn.State != System.Data.ConnectionState.Closed)
                {
                    objSQLConn.Close();
                }
            }
            return(lstCategory);
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            IInventoryManagerBLL objBLL       = InventoryManagerBLLFactory.CreateInventoryManagerBLLObject();
            IItemCategory        objcategory1 = ItemCategotyBOFactory.CreateItemCategoryObject();
            //List<IVendor> vendorList = objBLL.GetVendorDetails();
            List <IItemCategory> cateogies = new List <IItemCategory>();
            int vendorid = Convert.ToInt32(Request.QueryString["VendorID"]);

            if (!IsPostBack)
            {
                cateogies = objBLL.GetItemCategory();
                chkVendorItemCategory.DataSource     = cateogies;
                chkVendorItemCategory.DataTextField  = "CategoryName";
                chkVendorItemCategory.DataValueField = "CategoryID";
                chkVendorItemCategory.DataBind();

                if (vendorid != 0)//update
                {
                    IVendor objVendor = VendorBOFactory.CreateVendorObject();
                    objVendor        = objBLL.GetVendorByVendorId(vendorid);
                    lblMessage2.Text = "Vendor Id is:" + objVendor.VendorId;
                    vendorid         = Convert.ToInt32(Request.QueryString["VendorID"]);


                    objVendor.VendorId = vendorid;

                    txtOrganization.Text   = Convert.ToString(objVendor.NameOfOrganisation);
                    objVendor.CategoryList = objBLL.getVendorCategoryList(objVendor.VendorId);



                    for (int i = 0; i < chkVendorItemCategory.Items.Count; i++)
                    {
                        int categoryId = objVendor.CategoryList.Find(delegate(int cID) { return(cID == Convert.ToInt32(chkVendorItemCategory.Items[i].Value)); });
                        if (categoryId != 0)
                        {
                            chkVendorItemCategory.Items[i].Selected = true;
                        }
                    }
                    chkVendorItemCategory.SelectedValue = Convert.ToString(objVendor.CategoryList);

                    txtName.Text               = Convert.ToString(objVendor.NameOfContactPerson);
                    txtAddress.Text            = Convert.ToString(objVendor.Address);
                    txtEmail.Text              = Convert.ToString(objVendor.EmailId);
                    ddlState.SelectedItem.Text = Convert.ToString(objVendor.State);
                    ddlState_SelectedIndexChanged(sender, e);



                    ddlCity.SelectedItem.Text = Convert.ToString(objVendor.City);
                    txtContact.Text           = Convert.ToString(objVendor.ContactNumber);

                    ddlType.SelectedItem.Text = Convert.ToString(objVendor.VendorType);
                }
                else//add
                {
                    chkVendorItemCategory.SelectedValue = Convert.ToString(objVendor.CategoryList);
                    txtOrganization.Text   = Convert.ToString(objVendor.NameOfOrganisation);
                    txtName.Text           = Convert.ToString(objVendor.NameOfContactPerson);
                    txtAddress.Text        = Convert.ToString(objVendor.Address);
                    txtEmail.Text          = Convert.ToString(objVendor.EmailId);
                    ddlState.SelectedValue = Convert.ToString(objVendor.State);



                    ddlCity.SelectedValue = Convert.ToString(objVendor.City);
                    txtContact.Text       = Convert.ToString(objVendor.ContactNumber);

                    ddlType.SelectedValue = Convert.ToString(objVendor.VendorType);
                }
            }
        }