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

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

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

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

            pInn.Sort = "IIN";
            cboIIN.Properties.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);
            //    listCat.Tag = dtProd.Rows[0]["ID"];
            //    lstCat.Items.Add(listCat);
            //    //txtCatCode.Text = dtProd.Rows[0]["CategoryCode"].ToString() + "-" + dtProd.Rows[0]["SubCategoryCode"].ToString();
            //}
            if(_categoryId == 0)
            {
                PopulateFields();
            }
        }
        /// <summary>
        /// Populates lookups and tables
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void SystemSetting_Load(object sender, EventArgs e)
        {
            PopulatePrograms();
            // TAb IIN
            BLL.INN innInfo = new INN();
            innInfo.LoadAll();
            innInfo.Sort = "IIN";
            PopulateINN(innInfo);

            // TAb Category

            BLL.Type type = new BLL.Type();
            type.LoadAll();
            lkCategory.DataSource = type.DefaultView;

            PopulateCategoryTree();
            //unit section
            BLL.Unit uni = new Unit();
            uni.LoadAll();
            lstUnits.DataSource = uni.DefaultView;

            // dosage form section
            DosageForm doForm = new DosageForm();
            doForm.LoadAll();
            doForm.Sort = "Form";
            PopulateDosageForm(doForm);
            //receiving status section
            // PopulateManufacturer();
            //disposal reasons
            DisposalReasons reason = new DisposalReasons();
            reason.LoadAll();
            reason.Sort = "Reason";
            PopulateDisposalReason(reason);
            //location regions zones and woredas
            PopulateLocationTree();
            PopulateSupplyCatTree();

            PopulateBalance();
        }
 /// <summary>
 /// Handles the gridViewDosageForm focused node changed and updates the form accordingly
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void gridViewDosageForm_FocusedRowChanged(object sender, DevExpress.XtraGrid.Views.Base.FocusedRowChangedEventArgs e)
 {
     DataRow dr = gridViewDosageForm.GetFocusedDataRow();
     if (dr != null)
     {
         DosageForm doForm = new DosageForm();
         int formId = Convert.ToInt32(dr["ID"]);
         doForm.LoadByPrimaryKey(formId);
         txtDosageForm.Text = doForm.Form;
         txtDosageDescription.Text = doForm.Description;
         // if (doForm.TypeID == 1)
         rdDosDrug.Checked = ((doForm.TypeID == 1) ? true : false);
         rdDosSupply.Checked = ((doForm.TypeID == 2) ? true : false);
         _dosageFormId = doForm.ID;
         btnDosageSave.Text = "Update";
     }
 }
 private void PopulateDosageForm(DosageForm doForm)
 {
     gridDosageForm.DataSource = doForm.DefaultView;
 }
 private void btnDosageSave_Click(object sender, EventArgs e)
 {
     if (txtDosageForm.Text != "")
     {
         DosageForm doForm = new DosageForm();
         if (_dosageFormId != 0)
             doForm.LoadByPrimaryKey(_dosageFormId);
         else
             doForm.AddNew();
         doForm.Form = txtDosageForm.Text;
         doForm.Description = txtDosageDescription.Text;
         doForm.TypeID = ((rdDosDrug.Checked) ? 1 : 2);
         doForm.Save();
         doForm.LoadAll();
         PopulateDosageForm(doForm);
         ResetDosageForm();
     }
     else
     {
         txtDosageForm.BackColor = Color.White;
     }
 }