示例#1
0
 /// <summary>
 /// Save location related information
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void btnSaveLocation_Click(object sender, EventArgs e)
 {
     if (_locationType == "Reg")
     {
         BLL.Region reg = new BLL.Region();
         if (_locId != 0)
         {
             reg.LoadByPrimaryKey(_locId);
         }
         else
         {
             reg.AddNew();
         }
         reg.RegionName = cboRegion.Text;
         reg.RegionCode = txtCode.Text;
         reg.Save();
     }
     else if (_locationType == "Zon")
     {
         Zone zn = new Zone();
         if (_locId != 0)
         {
             zn.LoadByPrimaryKey(_locId);
         }
         else
         {
             zn.AddNew();
         }
         zn.ZoneName = cboZone.Text;
         zn.RegionId = Convert.ToInt32(cboRegion.SelectedValue);
         zn.ZoneCode = txtCode.Text;
         zn.Save();
     }
     else if (_locationType == "Wrd")
     {
         Woreda wrd = new Woreda();
         if (_locId != 0)
         {
             wrd.LoadByPrimaryKey(_locId);
         }
         else
         {
             wrd.AddNew();
         }
         wrd.WoredaName = cboWoreda.Text;
         wrd.ZoneID     = Convert.ToInt32(cboZone.SelectedValue);
         wrd.WoredaCode = txtCode.Text;
         wrd.Save();
     }
     PopulateLocationTree();
 }
 private void Hospital_Load(object sender, EventArgs e)
 {
     SetPermission();
        BLL.Region reg = new BLL.Region();
     reg.LoadAll();
     //cboRegion.DataSource = reg.DefaultView;
     Zone zon = new Zone();
     zon.LoadAll();
     //cboZone.DataSource = zon.DefaultView;
     Woreda wor = new Woreda();
     wor.LoadAll();
     //cboWoreda.DataSource = wor.DefaultView;
     PopulateFields();
 }
        private void Hospital_Load(object sender, EventArgs e)
        {
            SetPermission();
            BLL.Region reg = new BLL.Region();
            reg.LoadAll();
            //cboRegion.DataSource = reg.DefaultView;
            Zone zon = new Zone();

            zon.LoadAll();
            //cboZone.DataSource = zon.DefaultView;
            Woreda wor = new Woreda();

            wor.LoadAll();
            //cboWoreda.DataSource = wor.DefaultView;
            PopulateFields();
        }
示例#4
0
        /// <summary>
        /// Handles double click event of the location tree
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void locationTree_NodeMouseDoubleClick(object sender, TreeNodeMouseClickEventArgs e)
        {
            BLL.Region rgn        = new BLL.Region();
            Zone       zon        = new Zone();
            Woreda     wrd        = new Woreda();
            string     value      = locationTree.SelectedNode.Name;
            string     type       = value.Substring(0, 3);
            int        len        = value.Length - 3;
            int        locationId = Convert.ToInt32(value.Substring(3, len));

            if (type == "Reg")
            {
                rgn.LoadByPrimaryKey(locationId);
                cboRegion.SelectedValue = rgn.ID.ToString();
                txtCode.Text            = rgn.RegionCode;
                cboWoreda.Enabled       = false;
                cboZone.Enabled         = false;
                cboRegion.Enabled       = true;
                _locId = rgn.ID;
            }
            else if (type == "Zon")
            {
                zon.LoadByPrimaryKey(locationId);
                cboZone.SelectedValue   = zon.ID.ToString();
                txtCode.Text            = zon.ZoneCode;
                cboRegion.SelectedValue = zon.RegionId.ToString();
                cboWoreda.Enabled       = false;
                cboRegion.Enabled       = true;
                cboZone.Enabled         = true;
                _locId = zon.ID;
            }
            else if (type == "Wrd")
            {
                wrd.LoadByPrimaryKey(locationId);
                cboWoreda.SelectedValue = wrd.ID.ToString();
                txtCode.Text            = wrd.WoredaCode;
                cboZone.SelectedValue   = wrd.ZoneID.ToString();
                zon.LoadByPrimaryKey(wrd.ZoneID);
                cboRegion.SelectedValue = zon.RegionId.ToString();
                cboWoreda.Enabled       = true;
                cboRegion.Enabled       = true;
                cboZone.Enabled         = true;
                _locId = wrd.ID;
            }
            _locationType = type;
        }
示例#5
0
        /// <summary>
        /// Loads the location tree
        /// </summary>
        private void PopulateLocationTree()
        {
            BLL.Region reg = new BLL.Region();
            Zone       zon = new Zone();
            Woreda     wrd = new Woreda();

            reg.LoadAll();
            locationTree.Nodes.Clear();
            foreach (DataRowView dv in reg.DefaultView)
            {
                TreeNode nodes = new TreeNode
                {
                    Name        = "Reg" + dv["ID"].ToString(),
                    Text        = dv["RegionName"].ToString(),
                    ToolTipText = "Double Click to Edit."
                };
                zon.GetZoneByRegion(Convert.ToInt32(dv["ID"]));
                foreach (DataRowView subDv in zon.DefaultView)
                {
                    TreeNode zonNodes = new TreeNode
                    {
                        Name        = "Zon" + subDv["ID"].ToString(),
                        Text        = subDv["ZoneName"].ToString(),
                        ToolTipText = "Double Click to Edit."
                    };
                    wrd.GetWoredaByZone(Convert.ToInt32(subDv["ID"]));
                    foreach (DataRowView worDv in wrd.DefaultView)
                    {
                        TreeNode wrdNodes = new TreeNode
                        {
                            Name        = "Wrd" + worDv["ID"].ToString(),
                            Text        = worDv["WoredaName"].ToString(),
                            ToolTipText = "Double Click to Edit."
                        };
                        zonNodes.Nodes.Add(wrdNodes);
                    }
                    nodes.Nodes.Add(zonNodes);
                }
                locationTree.Nodes.Add(nodes);
            }

            cboRegion.DataSource = reg.DefaultView;
        }
示例#6
0
        private void LoadReceivingUnits()
        {
            BLL.Region reg = new BLL.Region();
            reg.LoadAll();
            lkRegion.Properties.DataSource = reg.DefaultView;

            BLL.InstitutionType ruType = new InstitutionType();
            ruType.Where.IsActive.Value = 1;
            ruType.Query.Load();
            lkRUType.Properties.DataSource = ruType.DefaultView;

            BLL.OwnershipType ownershipType = new OwnershipType();
            ownershipType.LoadAll();
            lkOwnership.Properties.DataSource = ownershipType.DefaultView;

            Route r = new Route();

            r.LoadAll();
            lkRoute.Properties.DataSource = r.DefaultView;
        }
示例#7
0
        private void ReceivingUnitsDetails_Load(object sender, EventArgs e)
        {
            LoadReceivingUnits();

            if (ID != -1)
            {
                lcExistingInstitutions.Visibility = LayoutVisibility.Never;
                lcIsUsedInFacility.Visibility     = LayoutVisibility.Always;

                int         selected = ID;
                Institution recUnit  = new Institution();
                recUnit.LoadByPrimaryKey(selected);
                txtReceivingUnit.Text    = recUnit.IsColumnNull("Name") ? "" : recUnit.Name;;
                txtReceivingUnit.Enabled = false;
                txtDescription.Text      = recUnit.IsColumnNull("Description") ? "" : recUnit.Description;
                txtPhone.Text            = recUnit.IsColumnNull("Phone") ? "" : recUnit.Phone;

                if (!recUnit.IsColumnNull("Ownership"))
                {
                    lkOwnership.EditValue = recUnit.Ownership;
                }
                if (!recUnit.IsColumnNull("RUType"))
                {
                    lkRUType.EditValue = recUnit.RUType;
                }
                txtLicenseNo.Text = recUnit.IsColumnNull("LicenseNo") ? "" : recUnit.LicenseNo;
                txtVATNo.Text     = recUnit.IsColumnNull("VATNo") ? "" : recUnit.VATNo;
                txtTinNo.Text     = recUnit.IsColumnNull("TinNo") ? "" : recUnit.TinNo;

                chkIsInstitutionUsedAtFacility.Checked = recUnit.IsColumnNull("IsUsedAtFacility") ? false : recUnit.IsUsedAtFacility;
                dtRegistration.Value = recUnit.IsColumnNull("DateOfRegistration") ? DateTimeHelper.ServerDateTime : recUnit.DateOfRegistration;
                if (!recUnit.IsColumnNull("Woreda"))
                {
                    BLL.Woreda woreda = new Woreda();
                    woreda.LoadByPrimaryKey(recUnit.Woreda);

                    BLL.Zone zone = new Zone();
                    zone.LoadByPrimaryKey(woreda.ZoneID);

                    BLL.Region region = new BLL.Region();
                    region.LoadByPrimaryKey(zone.RegionId);

                    lkRegion.EditValue = region.ID;

                    lkZone.Properties.DataSource = BLL.Zone.GetZoneByRegion(region.ID).DefaultView;
                    lkZone.EditValue             = zone.ID;

                    Woreda.GetWoredaByZone(zone.ID);
                    lkWoreda.Properties.DataSource = woreda.DefaultView;
                    lkWoreda.EditValue             = recUnit.Woreda;
                }
                else if (!recUnit.IsColumnNull("Zone")) //We allow the Woreda to be empty so, let's check the zone now.
                {
                    BLL.Zone zone = new Zone();
                    zone.LoadByPrimaryKey(recUnit.Zone);

                    BLL.Region region = new BLL.Region();
                    region.LoadByPrimaryKey(zone.RegionId);

                    lkRegion.EditValue = region.ID;

                    lkZone.Properties.DataSource = BLL.Zone.GetZoneByRegion(region.ID).DefaultView;
                    lkZone.EditValue             = zone.ID;
                }
                else
                {
                    lkRegion.EditValue = null;
                    lkZone.EditValue   = null;
                    lkWoreda.EditValue = null;
                }

                Route r = new Route();
                r.LoadAll();
                lkRoute.Properties.DataSource = r.DefaultView;

                lkRoute.EditValue = (recUnit.IsColumnNull("Route")) ? 0 : recUnit.Route;
                receivingUnitId   = recUnit.ID;

                bool isItDraft = !recUnit.IsColumnNull("IsDraft") && recUnit.IsDraft &&
                                 (BLL.Order.GetTotalForAnInstitution(recUnit.ID) == 0);

                lkRegion.Enabled         = isItDraft;
                lkZone.Enabled           = isItDraft;
                lkWoreda.Enabled         = isItDraft;
                lkRUType.Enabled         = isItDraft;
                lkOwnership.Enabled      = isItDraft;
                txtReceivingUnit.Enabled = isItDraft;
            }
            else
            {
                lcExistingInstitutions.Visibility = LayoutVisibility.Always;
                lcIsUsedInFacility.Visibility     = LayoutVisibility.Never;
            }
        }
        private void ReceivingUnitsDetails_Load(object sender, EventArgs e)
        {
            LoadReceivingUnits();

            if (ID != -1)
            {

                lcExistingInstitutions.Visibility = LayoutVisibility.Never;
                lcIsUsedInFacility.Visibility = LayoutVisibility.Always;

                int selected = ID;
                Institution recUnit = new Institution();
                recUnit.LoadByPrimaryKey(selected);
                txtReceivingUnit.Text = recUnit.IsColumnNull("Name") ? "" : recUnit.Name;;
                txtReceivingUnit.Enabled = false;
                txtDescription.Text = recUnit.IsColumnNull("Description") ? "" : recUnit.Description;
                txtPhone.Text = recUnit.IsColumnNull("Phone") ? "" : recUnit.Phone;

                if (!recUnit.IsColumnNull("Ownership"))
                    lkOwnership.EditValue = recUnit.Ownership;
                if (!recUnit.IsColumnNull("RUType"))
                    lkRUType.EditValue = recUnit.RUType;
                txtLicenseNo.Text = recUnit.IsColumnNull("LicenseNo") ? "" : recUnit.LicenseNo;
                txtVATNo.Text = recUnit.IsColumnNull("VATNo") ? "" : recUnit.VATNo;
                txtTinNo.Text = recUnit.IsColumnNull("TinNo") ? "" : recUnit.TinNo;

                chkIsInstitutionUsedAtFacility.Checked = recUnit.IsColumnNull("IsUsedAtFacility") ? false : recUnit.IsUsedAtFacility;
                dtRegistration.Value = recUnit.IsColumnNull("DateOfRegistration") ? DateTimeHelper.ServerDateTime : recUnit.DateOfRegistration;
                if (!recUnit.IsColumnNull("Woreda"))
                {
                    BLL.Woreda woreda = new Woreda();
                    woreda.LoadByPrimaryKey(recUnit.Woreda);

                    BLL.Zone zone = new Zone();
                    zone.LoadByPrimaryKey(woreda.ZoneID);

                    BLL.Region region = new BLL.Region();
                    region.LoadByPrimaryKey(zone.RegionId);

                    lkRegion.EditValue = region.ID;

                    lkZone.Properties.DataSource = BLL.Zone.GetZoneByRegion(region.ID).DefaultView;
                    lkZone.EditValue = zone.ID;

                    Woreda.GetWoredaByZone(zone.ID);
                    lkWoreda.Properties.DataSource = woreda.DefaultView;
                    lkWoreda.EditValue = recUnit.Woreda;
                }
                else if (!recUnit.IsColumnNull("Zone")) //We allow the Woreda to be empty so, let's check the zone now.
                {
                    BLL.Zone zone = new Zone();
                    zone.LoadByPrimaryKey(recUnit.Zone);

                    BLL.Region region = new BLL.Region();
                    region.LoadByPrimaryKey(zone.RegionId);

                    lkRegion.EditValue = region.ID;

                    lkZone.Properties.DataSource = BLL.Zone.GetZoneByRegion(region.ID).DefaultView;
                    lkZone.EditValue = zone.ID;
                }
                else
                {
                    lkRegion.EditValue = null;
                    lkZone.EditValue = null;
                    lkWoreda.EditValue = null;
                }

                Route r = new Route();
                r.LoadAll();
                lkRoute.Properties.DataSource = r.DefaultView;

                lkRoute.EditValue = (recUnit.IsColumnNull("Route")) ? 0 : recUnit.Route;
                receivingUnitId = recUnit.ID;

                bool isItDraft = !recUnit.IsColumnNull("IsDraft") && recUnit.IsDraft &&
                                 (BLL.Order.GetTotalForAnInstitution(recUnit.ID) == 0);

                lkRegion.Enabled = isItDraft;
                lkZone.Enabled = isItDraft;
                lkWoreda.Enabled = isItDraft;
                lkRUType.Enabled = isItDraft;
                lkOwnership.Enabled = isItDraft;
                txtReceivingUnit.Enabled = isItDraft;

            }
            else
            {
                lcExistingInstitutions.Visibility=LayoutVisibility.Always;
                lcIsUsedInFacility.Visibility = LayoutVisibility.Never;
            }
        }
        private void LoadReceivingUnits()
        {
            BLL.Region reg = new BLL.Region();
            reg.LoadAll();
            lkRegion.Properties.DataSource = reg.DefaultView;

            BLL.InstitutionType ruType = new InstitutionType();
            ruType.Where.IsActive.Value = 1;
            ruType.Query.Load();
            lkRUType.Properties.DataSource = ruType.DefaultView;

            BLL.OwnershipType ownershipType = new OwnershipType();
            ownershipType.LoadAll();
            lkOwnership.Properties.DataSource = ownershipType.DefaultView;

            Route r = new Route();
            r.LoadAll();
            lkRoute.Properties.DataSource = r.DefaultView;
        }
        /// <summary>
        /// Loads the location tree
        /// </summary>
        private void PopulateLocationTree()
        {
            BLL.Region reg = new BLL.Region();
            Zone zon = new Zone();
            Woreda wrd = new Woreda();
            reg.LoadAll();
            locationTree.Nodes.Clear();
            foreach (DataRowView dv in reg.DefaultView)
            {
                TreeNode nodes = new TreeNode
                                     {
                                         Name = "Reg" + dv["ID"].ToString(),
                                         Text = dv["RegionName"].ToString(),
                                         ToolTipText = "Double Click to Edit."
                                     };
                zon.GetZoneByRegion(Convert.ToInt32(dv["ID"]));
                foreach (DataRowView subDv in zon.DefaultView)
                {
                    TreeNode zonNodes = new TreeNode
                                            {
                                                Name = "Zon" + subDv["ID"].ToString(),
                                                Text = subDv["ZoneName"].ToString(),
                                                ToolTipText = "Double Click to Edit."
                                            };
                    wrd.GetWoredaByZone(Convert.ToInt32(subDv["ID"]));
                    foreach (DataRowView worDv in wrd.DefaultView)
                    {
                        TreeNode wrdNodes = new TreeNode
                                                {
                                                    Name = "Wrd" + worDv["ID"].ToString(),
                                                    Text = worDv["WoredaName"].ToString(),
                                                    ToolTipText = "Double Click to Edit."
                                                };
                        zonNodes.Nodes.Add(wrdNodes);
                    }
                    nodes.Nodes.Add(zonNodes);
                }
                locationTree.Nodes.Add(nodes);
            }

            cboRegion.DataSource = reg.DefaultView;
        }
        /// <summary>
        /// Handles double click event of the location tree
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void locationTree_NodeMouseDoubleClick(object sender, TreeNodeMouseClickEventArgs e)
        {
            BLL.Region rgn = new BLL.Region();
            Zone zon = new Zone();
            Woreda wrd = new Woreda();
            string value = locationTree.SelectedNode.Name;
            string type = value.Substring(0, 3);
            int len = value.Length - 3;
            int locationId = Convert.ToInt32(value.Substring(3, len));
            if (type == "Reg")
            {
                rgn.LoadByPrimaryKey(locationId);
                cboRegion.SelectedValue = rgn.ID.ToString();
                txtCode.Text = rgn.RegionCode;
                cboWoreda.Enabled = false;
                cboZone.Enabled = false;
                cboRegion.Enabled = true;
                _locId = rgn.ID;
            }
            else if (type == "Zon")
            {
                zon.LoadByPrimaryKey(locationId);
                cboZone.SelectedValue = zon.ID.ToString();
                txtCode.Text = zon.ZoneCode;
                cboRegion.SelectedValue = zon.RegionId.ToString();
                cboWoreda.Enabled = false;
                cboRegion.Enabled = true;
                cboZone.Enabled = true;
                _locId = zon.ID;
            }
            else if (type == "Wrd")
            {
                wrd.LoadByPrimaryKey(locationId);
                cboWoreda.SelectedValue = wrd.ID.ToString();
                txtCode.Text = wrd.WoredaCode;
                cboZone.SelectedValue = wrd.ZoneID.ToString();
                zon.LoadByPrimaryKey(wrd.ZoneID);
                cboRegion.SelectedValue = zon.RegionId.ToString();
                cboWoreda.Enabled = true;
                cboRegion.Enabled = true;
                cboZone.Enabled = true;
                _locId = wrd.ID;

            }
            _locationType = type;
        }
        /// <summary>
        /// Save location related information
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnSaveLocation_Click(object sender, EventArgs e)
        {
            if (_locationType == "Reg")
            {
                BLL.Region reg = new BLL.Region();
                if (_locId != 0)
                    reg.LoadByPrimaryKey(_locId);
                else
                    reg.AddNew();
                reg.RegionName = cboRegion.Text;
                reg.RegionCode = txtCode.Text;
                reg.Save();

            }
            else if (_locationType == "Zon")
            {
                Zone zn = new Zone();
                if (_locId != 0)
                    zn.LoadByPrimaryKey(_locId);
                else
                    zn.AddNew();
                zn.ZoneName = cboZone.Text;
                zn.RegionId = Convert.ToInt32(cboRegion.SelectedValue);
                zn.ZoneCode = txtCode.Text;
                zn.Save();
            }
            else if (_locationType == "Wrd")
            {
                Woreda wrd = new Woreda();
                if (_locId != 0)
                    wrd.LoadByPrimaryKey(_locId);
                else
                    wrd.AddNew();
                wrd.WoredaName = cboWoreda.Text;
                wrd.ZoneID = Convert.ToInt32(cboZone.SelectedValue);
                wrd.WoredaCode = txtCode.Text;
                wrd.Save();
            }
            PopulateLocationTree();
        }