/// <summary> /// Gets the zone by region and number Receiving Units. /// </summary> /// <param name="regionId">The region id.</param> /// <param name="storeID">The store ID.</param> /// <param name="issuedTo">if set to <c>true</c> [issued to].</param> /// <returns></returns> public static DataTable GetZoneByRegionAndNumberRU(int regionId,int storeID, bool issuedTo) { Zone zones = new Zone(); var query = HCMIS.Repository.Queries.Zone.SelectGetZoneByRegionAndNumberRU(regionId, storeID); Institution institution = new Institution(); zones.LoadFromRawSql(query); return zones.DataTable; }
/// <summary> /// Returns list of zones in region /// </summary> /// <param name="regionId">The region id.</param> /// <returns></returns> public static Zone GetZoneByRegion(int regionId) { Zone zone = new Zone(); zone.FlushData(); zone.Where.WhereClauseReset(); zone.Where.RegionId.Value = regionId; zone.Query.Load(); return zone; }
private void lkForFacility_EditValueChanged(object sender, EventArgs e) { if (lkForFacility.EditValue == null) return; FacilityChanged(lkForFacility); Institution ru = new Institution(); ru.LoadByPrimaryKey(Convert.ToInt32(lkForFacility.EditValue)); if (!ru.IsColumnNull("Woreda")) { BLL.Woreda woreda = new BLL.Woreda(); woreda.LoadByPrimaryKey(ru.Woreda); BLL.Zone zone = new BLL.Zone(); zone.LoadByPrimaryKey(woreda.ZoneID); lkRegion.EditValue = zone.RegionId; lkZone.EditValue = zone.ID; lkWoreda.EditValue = ru.Woreda; } lkOwnership.EditValue = ru.Ownership; lkType.EditValue = ru.RUType; //Fill facility visit history DataRow facilityHis = BLL.Issue.GetVisitHistoryForFacility((int)lkForFacility.EditValue); NoOfVisitLabel.Text = facilityHis != null ? Convert.ToInt32(facilityHis["VisitCount"]).ToString(CultureInfo.InvariantCulture) : "0"; LastVisitlabel.Text = facilityHis != null ? Convert.ToDateTime(facilityHis["LastVisit"]).TimeAgo() : "Never"; //Reset Requisitoin Type if(!BLL.Settings.IsCenter && OrderID == null && Type == RequisitionType.History) lkRequisitionType_EditValueChanged(null, null); }
public void EditRequisition(int orderID) { OrderID = orderID; Order ord = new Order(); ord.LoadByPrimaryKey(orderID); txtRefNo.Text = ord.RefNo; txtLetterNumber.Text = ord.LetterNo; labelControl4.Text = ord.RefNo; Institution ru = new Institution(); ru.LoadByPrimaryKey(ord.RequestedBy); if (!ru.IsColumnNull("Zone")) { // Just because the region Property on the Receiving Unit is not working as desired. Zone zone = new Zone(); zone.LoadByPrimaryKey(ru.Zone); lkRegion.EditValue = zone.RegionId; lkZone.EditValue = ru.Zone; } lkForFacility.EditValue = ru.ID; lkModes.EditValue = ord.FromStore; lkModes_EditValueChanged(null, null); lkPaymentType.EditValue = ord.PaymentTypeID; txtContactPerson.EditValue = ord.ContactPerson; BLL.OrderDetail or = new BLL.OrderDetail(); or.LoadAllByOrderID(orderID); DataView selectables = (DataView)gridItemChoiceView.DataSource; if (_dtSelectedTable != null) { _dtSelectedTable.Clear(); } else { PopulateItemsList(); } while (!or.EOF) { // select the items and put it in the dtselected table. if (selectables != null) { DataRow[] dataRows = selectables.Table.Select(String.Format("ID = {0} and UnitID = {1}", or.ItemID, or.UnitID)); if (dataRows.Length > 0) { _dtSelectedTable.ImportRow(dataRows[0]); dataRows[0]["IsSelected"] = true; } } or.MoveNext(); } _dvOrderTable = or.DefaultView; orderGrid.DataSource = _dvOrderTable; EnableDisableButtons(); }
//TODO: Wire up all 3 stations if variable range interceptors are allowed public SittingDuck() { CurrentThreatBuffs = new Dictionary<ExternalThreat, ExternalThreatBuff>(); CurrentInternalThreats = new List<InternalThreat>(); CurrentExternalThreats = new List<ExternalThreat>(); var whiteReactor = new CentralReactor(); var redReactor = new SideReactor(whiteReactor); var blueReactor = new SideReactor(whiteReactor); var redBatteryPack = new BatteryPack(); var blueBatteryPack = new BatteryPack(); var computerComponent = new ComputerComponent(); var visualConfirmationComponent = new VisualConfirmationComponent(); var rocketsComponent = new RocketsComponent(); Computer = computerComponent; VisualConfirmationComponent = visualConfirmationComponent; RocketsComponent = rocketsComponent; var interceptorStation = new InterceptorStation { StationLocation = StationLocation.Interceptor }; var upperRedStation = new StandardStation { Cannon = new SideHeavyLaserCannon(redReactor, ZoneLocation.Red), EnergyContainer = new SideShield(redReactor), StationLocation = StationLocation.UpperRed }; interceptorStation.InterceptorComponent = new InterceptorComponent(null, upperRedStation); upperRedStation.CComponent = new InterceptorComponent(interceptorStation, null); var upperWhiteStation = new StandardStation { Cannon = new CentralHeavyLaserCannon(whiteReactor, ZoneLocation.White), EnergyContainer = new CentralShield(whiteReactor), StationLocation = StationLocation.UpperWhite, CComponent = computerComponent }; var upperBlueStation = new StandardStation { Cannon = new SideHeavyLaserCannon(blueReactor, ZoneLocation.Blue), EnergyContainer = new SideShield(blueReactor), StationLocation = StationLocation.UpperBlue, CComponent = new BattleBotsComponent() }; var lowerRedStation = new StandardStation { Cannon = new SideLightLaserCannon(redBatteryPack, ZoneLocation.Red), EnergyContainer = redReactor, StationLocation = StationLocation.LowerRed, CComponent = new BattleBotsComponent() }; var lowerWhiteStation = new StandardStation { Cannon = new PulseCannon(whiteReactor), EnergyContainer = whiteReactor, StationLocation = StationLocation.LowerWhite, CComponent = visualConfirmationComponent }; var lowerBlueStation = new StandardStation { Cannon = new SideLightLaserCannon(blueBatteryPack, ZoneLocation.Blue), EnergyContainer = blueReactor, StationLocation = StationLocation.LowerBlue, CComponent = rocketsComponent }; upperRedStation.BluewardStation = upperWhiteStation; upperRedStation.OppositeDeckStation = lowerRedStation; upperWhiteStation.RedwardStation = upperRedStation; upperWhiteStation.BluewardStation = upperBlueStation; upperWhiteStation.OppositeDeckStation = lowerWhiteStation; upperBlueStation.RedwardStation = upperWhiteStation; upperBlueStation.OppositeDeckStation = lowerBlueStation; lowerRedStation.BluewardStation = lowerWhiteStation; lowerRedStation.OppositeDeckStation = upperRedStation; lowerWhiteStation.RedwardStation = lowerRedStation; lowerWhiteStation.BluewardStation = lowerBlueStation; lowerWhiteStation.OppositeDeckStation = upperWhiteStation; lowerBlueStation.RedwardStation = lowerWhiteStation; lowerBlueStation.OppositeDeckStation = upperBlueStation; RedZone = new Zone { LowerStation = lowerRedStation, UpperStation = upperRedStation, ZoneLocation = ZoneLocation.Red, Gravolift = new Gravolift() }; WhiteZone = new Zone { LowerStation = lowerWhiteStation, UpperStation = upperWhiteStation, ZoneLocation = ZoneLocation.White, Gravolift = new Gravolift() }; BlueZone = new Zone { LowerStation = lowerBlueStation, UpperStation = upperBlueStation, ZoneLocation = ZoneLocation.Blue, Gravolift = new Gravolift() }; ZonesByLocation = new[] {RedZone, WhiteZone, BlueZone}.ToDictionary(zone => zone.ZoneLocation); StationByLocation = Zones .SelectMany(zone => new[] {zone.LowerStation, zone.UpperStation}) .Concat(new Station[] {interceptorStation}) .ToDictionary(station => station.StationLocation); InterceptorStation = interceptorStation; }
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 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; } }
/// <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> /// Populates the zones /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void cboRegion_SelectedIndexChanged(object sender, EventArgs e) { Zone zn = new Zone(); zn.GetZoneByRegion(Convert.ToInt32(cboRegion.SelectedValue)); cboZone.DataSource = zn.DefaultView; }
/// <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(); }