private void AddItem_Load(object sender, EventArgs e)
        {
            DosageForm doFrm = new DosageForm();
            doFrm.GetDosageForItem();

            doFrm.Sort = "Form";
            cboDosageForm.DataSource = doFrm.DefaultView;

            Unit un = new Unit();
            un.LoadAll();
            un.Sort = "Unit";
            cboUnit.DataSource = un.DefaultView;

            Product pInn = new Product();
            pInn.GetInnForItem();

            pInn.Sort = "IIN";
            cboIIN.DataSource = pInn.DefaultView;

            if (_categoryId != 0)
            {
                SubCategory cat = new SubCategory();
                DataTable dtProd = cat.GetSubCategoryByID(_categoryId);
                string[] categor = { dtProd.Rows[0]["CategoryName"].ToString(), dtProd.Rows[0]["SubCategoryName"].ToString() };
                ListViewItem listCat = new ListViewItem(categor) {Tag = dtProd.Rows[0]["ID"]};
                lstCat.Items.Add(listCat);
                //txtCatCode.Text = dtProd.Rows[0]["CategoryCode"].ToString() + "-" + dtProd.Rows[0]["SubCategoryCode"].ToString();
            }
            else
            {
                PopulateFields();
            }
        }
        private void ProductTree_NodeMouseDoubleClick(object sender, TreeNodeMouseClickEventArgs e)
        {
            try
            {
                Items itm = new Items();
                DataTable dtItem = new DataTable();
                string value = ProductTree.SelectedNode.Name;
                string type = value.Substring(0, 3);
                int len = value.Length - 3;
                int categoryId = Convert.ToInt32(value.Substring(3, len));

                if (type == "sub")
                {
                    SubCategory cat = new SubCategory();
                    DataTable dtProd = cat.GetSubCategoryByID(categoryId);
                    string[] categor = { dtProd.Rows[0]["CategoryName"].ToString(), dtProd.Rows[0]["SubCategoryName"].ToString() };
                    ListViewItem listCat = new ListViewItem(categor);
                    listCat.Tag = dtProd.Rows[0]["ID"];
                    lstCat.Items.Add(listCat);
                    ProductTree.Visible = false;
                }
            }
            catch
            { }
        }
        private void PopulateFields()
        {
            try
            {
                if (_itemId == 0) return;

                Items itm = new Items();

                itm.LoadByPrimaryKey(_itemId);
                SubCategory cat = new SubCategory();
                DataTable dtCat = cat.GetSubCategoryOfItem(_itemId);
                foreach (DataRow drcat in dtCat.Rows)
                {
                    DataTable dtProd = cat.GetSubCategoryByID(Convert.ToInt32(drcat["SubCategoryID"]));
                    //txtCategory.Text = dtProd.Rows[0]["CategoryName"].ToString();
                    //txtSubCategory.Text = dtProd.Rows[0]["SubCategoryName"].ToString();
                    string[] categor = { dtProd.Rows[0]["CategoryName"].ToString(), dtProd.Rows[0]["SubCategoryName"].ToString() };
                    ListViewItem listCat = new ListViewItem(categor) { Tag = dtProd.Rows[0]["ID"] };
                    lstCat.Items.Add(listCat);
                }
                cboIIN.SelectedValue = itm.IINID.ToString();
                Product nInn = new Product();
                nInn.LoadByPrimaryKey(itm.IINID);
                //txtATC.Text = nInn.ATC;
                txtStrength.Text = itm.Strength;
                ckIsDiscontinued.Checked = itm.IsDiscontinued;
                ckIsEDL.Checked = itm.EDL;
                ckIsFree.Checked = itm.IsFree;
                ckIsPedatric.Checked = itm.Pediatric;
                ckIsRefrigerated.Checked = itm.Refrigeratored;
                cboDosageForm.SelectedValue = itm.DosageFormID.ToString();
                cboUnit.SelectedValue = itm.UnitID.ToString();
                string code = itm.StockCode;
                txtStockCode.Text = code;
                txtStock2.Text = itm.Code;
                txtStock3.Text = itm.StockCodeDACA;
            }
            catch
            {

            }
        }