private void MainGrid_SelectedItemChanged(object sender, DevExpress.Xpf.Grid.SelectedItemChangedEventArgs e) { if (e.OldItem == null) { return; } model = e.NewItem as TCountry; EditGrid.DataContext = model; }
public void setLocation(TLocation selloc) { SelectedLocation = selloc; TCountry findCountry = (PrefferedCountry is TCountry ? PrefferedCountry as TCountry : null); comboBox1.BeginUpdate(); foreach (TCountry ct in TCountry.Countries) { comboBox1.Items.Add(ct); } comboBox1.Sorted = true; comboBox1.EndUpdate(); comboBox2.BeginUpdate(); foreach (TTimeZone tz in TTimeZone.TimeZoneList) { comboBox2.Items.Add(tz); } comboBox2.EndUpdate(); if (SelectedLocation == null) { textBox1.Text = "<new location>"; textBox2.Text = "12N50"; textBox3.Text = "50W13"; comboBox1.SelectedIndex = 0; comboBox2.SelectedIndex = 0; } else { textBox1.Text = SelectedLocation.CityName; for (int i = 0; i < comboBox1.Items.Count; i++) { TCountry tc = comboBox1.Items[i] as TCountry; if (tc.Name.Equals(SelectedLocation.Country.Name)) { comboBox1.SelectedIndex = i; break; } } textBox2.Text = GCEarthData.GetTextLatitude(SelectedLocation.Latitude); textBox3.Text = GCEarthData.GetTextLongitude(SelectedLocation.Longitude); for (int j = 0; j < comboBox2.Items.Count; j++) { TTimeZone tz = comboBox2.Items[j] as TTimeZone; if (tz.Name.Equals(SelectedLocation.TimeZoneName)) { comboBox2.SelectedIndex = j; break; } } } }
public override string GetFullText(Connection conn) { StringBuilder fullText = new StringBuilder(TCountry.Seek(country).name); if (foreign != "") { fullText.AppendFormat(" {0}", foreign); } return(fullText.ToString()); }
public static TypeCountry GetCountry(TCountry country) { switch (country) { case TCountry.tAustralia: return(new TypeAust()); case TCountry.tUnitedKingdom: return(new TypeUK()); } }
private bool IsCodeUnique() { if (textBox1.Enabled == false) { return(true); } TCountry tc = TCountry.FindCountryByISOCode(textBox1.Text); return(tc == null); }
void DelModel() { if (MainGrid.SelectedItem == null) { MessageBox.Show("请选择一行"); return; } if (MessageBox.Show("是否确认删除?", "删除确认", MessageBoxButton.YesNo) == MessageBoxResult.Yes) { model = MainGrid.SelectedItem as TCountry; visaORM.DeleteObject(model); countryCollection.Remove(model); } }
/// <summary> /// Edit /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void button2_Click(object sender, EventArgs e) { if (listView1.SelectedItems.Count == 0) { return; } TCountry sc = listView1.SelectedItems[0].Tag as TCountry; CountryDetails d = new CountryDetails(); d.OnButtonSave += new TBButtonPressed(OnCountryListChanged); d.SelectedCountry = sc; CountryDetailsController dc = new CountryDetailsController(d); dc.ShowInContainer(ViewContainer, GVControlAlign.Fill); }
private void buttonSetCountryByCity_Click(object sender, EventArgs e) { if (lastLocation != null) { TLocation loc = lastLocation; int i = 0; foreach (object c in comboBoxCountry.Items) { if (c is TCountry) { TCountry tc = c as TCountry; if (tc.ISOCode.Equals(loc.CountryISOCode)) { comboBoxCountry.SelectedIndex = i; break; } } i++; } } }
private void buttonSave_Click(object sender, EventArgs e) { if (_sc == null) { TCountry tc = new TCountry(); tc.ISOCode = textBox1.Text; tc.Name = textBox2.Text; tc.ContinentISOCode = SelectedContinent.ISOCode; TCountry.Countries.Add(tc); } else { _sc.ISOCode = textBox1.Text; _sc.Name = textBox2.Text; _sc.ContinentISOCode = SelectedContinent.ISOCode; } TCountry.Modified = true; Controller.RemoveFromContainer(); if (OnButtonSave != null) { OnButtonSave(this, e); } }
void NewModel() { model = new TCountry(); EditGrid.DataContext = model; }
public ReturnValue Run() { ReturnValue _result = new ReturnValue(); #region get ship method list TShipMethod _tShipMethod = new TShipMethod(); _result = _tShipMethod.getShipMethodList(); if (_result.Success == false) { _result.Success = false; _result.ErrMessage = "getShipMethodList failed. \r\n " + _result.ErrMessage; Common.Log("getShipMethodList---ER \r\n" + _result.ErrMessage); return(_result); } ShipMethods = _result.ObjectList.ConvertAll(t => t as TShipMethod); #endregion #region get product list TProgram_Product _tProgram_Product = new TProgram_Product(); _result = _tProgram_Product.getProgramProductList(); if (_result.Success == false) { _result.Success = false; _result.ErrMessage = "getProgramProductList failed. \r\n " + _result.ErrMessage; Common.Log("getProgramProductList---ER \r\n" + _result.ErrMessage); return(_result); } Products = _result.ObjectList.ConvertAll(t => t as TProgram_Product); #endregion #region get country list TCountry _tCountry = new TCountry(); _result = _tCountry.getCountryList(); if (_result.Success == false) { _result.Success = false; _result.ErrMessage = "getCountryList failed. \r\n " + _result.ErrMessage; Common.Log("getCountryList---ER \r\n" + _result.ErrMessage); return(_result); } Countrys = _result.ObjectList.ConvertAll(t => t as TCountry); #endregion #region get state list TState _tState = new TState(); _result = _tState.getStateList(); if (_result.Success == false) { _result.Success = false; _result.ErrMessage = "getStateList failed. \r\n " + _result.ErrMessage; Common.Log("getStateList---ER \r\n" + _result.ErrMessage); return(_result); } States = _result.ObjectList.ConvertAll(t => t as TState); #endregion #region get type list TType _tType = new TType(); _result = _tType.geTTypeList(); if (_result.Success == false) { _result.Success = false; _result.ErrMessage = "geTTypeList failed. \r\n " + _result.ErrMessage; Common.Log("geTTypeList---ER \r\n" + _result.ErrMessage); return(_result); } Types = _result.ObjectList.ConvertAll(t => t as TType); #endregion #region PULLOrders _result = SS2.ShipStationAPI.PULLOrders(); if (_result.Success == false) { _result.Success = false; _result.ErrMessage = "PULLOrders failed. \r\n " + _result.ErrMessage; Common.Log("PULLOrders---ER \r\n" + _result.ErrMessage); Common.SentAlterEmail(1, _result.ErrMessage); return(_result); } List <ShipStationResponseOrder> orderList = _result.ObjectValue as List <ShipStationResponseOrder>; #endregion foreach (ShipStationResponseOrder order in orderList) { #region check program ID if (string.IsNullOrWhiteSpace(order.advancedOptions.customField1) == true) { continue; } var programId = order.advancedOptions.customField1; Common.Log("ProgramID:" + programId + " Order : " + order.orderId + "---Start"); List <string> Programs = ConfigurationSettings.AppSettings["ProgramList"].Split(',').ToList(); if (Programs.Exists(p => p.Equals(programId)) == false) { _result.ErrMessage = "Program ID:" + programId + " is valid"; errorNotes = errorNotes + order.orderId + "\r\n" + _result.ErrMessage + "\r\n"; failedRecord++; Common.Log("ProgramID:" + programId + " Order : " + order.orderId + "---ER \r\n" + _result.ErrMessage); continue; } #endregion #region check order existed TShipStationOrders shipStationOrders = new TShipStationOrders(); _result = shipStationOrders.getOrderBySOrderId(order.orderId); if (_result.Success == false) { errorNotes = errorNotes + order.orderId + "\r\n" + _result.ErrMessage + "\r\n"; failedRecord++; Common.Log("ProgramID:" + programId + " Order : " + order.orderId + "---ER \r\n" + _result.ErrMessage); continue; } shipStationOrders = _result.Object as TShipStationOrders; if (shipStationOrders.ID != 0) { continue; } #endregion #region create ZStore Order _result = createZOrder(order); if (_result.Success == false) { errorNotes = errorNotes + order.orderId + "\r\n" + _result.ErrMessage + "\r\n"; failedRecord++; Common.Log("ProgramID:" + programId + " Order : " + order.orderId + "---ER \r\n" + _result.ErrMessage); continue; } TOrder _tOrder = _result.Object as TOrder; #endregion #region save Order _result = saveZOrder(_tOrder, order); if (_result.Success == false) { errorNotes = errorNotes + order.orderId + "\r\n" + _result.ErrMessage + "\r\n"; failedRecord++; Common.Log("ProgramID:" + programId + " Order : " + order.orderId + "---ER \r\n" + _result.ErrMessage); continue; } #endregion Common.Log("ProgramID:" + programId + " Order : " + order.orderId + "---OK"); } Common.SentAlterEmail(failedRecord, errorNotes); _result.Success = true; return(_result); }
/// <summary> /// Filling ListView with cities /// </summary> private void UpdateLocationList() { string sp = textBox1.Text.Trim(); bool emptySp = (sp.Length == 0); object obj = m_wndCountry.SelectedItem; TCountry country = (obj is TCountry) ? (obj as TCountry) : null; int A = 0, B = 100; int lastCompare = 2; listViewLocations.BeginUpdate(); listViewLocations.Items.Clear(); List <TLocation>[] p = { new List <TLocation>(), new List <TLocation>(), new List <TLocation>() }; foreach (TLocation L in TLocationDatabase.LocationList) { if (country == null || L.CountryISOCode.Equals(country.ISOCode)) { if (emptySp || (lastCompare = L.ContainsSubstring(sp)) > 0) { switch (lastCompare) { case 1: p[0].Add(L); break; case 2: p[1].Add(L); break; default: p[2].Add(L); break; } A++; } } if (A > B) { break; } } for (int j = 0; j < 3; j++) { foreach (TLocation L in p[j]) { listViewLocations.Items.Add(ListItemFromLocation(L)); } p[j].Clear(); } listViewLocations.EndUpdate(); if (A > B) { labelLimitInfo.Text = string.Format("Number of results limited to {0}", A); labelLimitInfo.ForeColor = Color.DarkRed; } else { labelLimitInfo.Text = string.Format("Number of results: {0}", A); labelLimitInfo.ForeColor = Color.DarkGreen; } }
/// <summary> /// 切换到打印预览 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void MainTab_SelectionChanged(object sender, SelectionChangedEventArgs e) { try { if (MainTab.SelectedIndex == 1) { if (cbAuditPerson.SelectedItem == null || cbAuditPosition.SelectedItem == null) { MainTab.SelectedIndex = 0; this.selectPrintSendInfopara = 1; MessageBox.Show("请选择审批人姓名和职位"); return; } if (this.selectPrintSendInfopara == 1) { if (string.IsNullOrEmpty(this.txtSendNO.Text) && cbNotPrint.SelectedItem == null) { MessageBox.Show("请选择需要打印的签证名单"); MainTab.SelectedIndex = 0; this.selectPrintSendInfopara = 1; return; } foreach (var sendObj in sendCollection.Where(s => s.FSelectItem == true)) { if (string.IsNullOrEmpty(sendObj.FQZID)) { MessageBox.Show("请先设置签证号"); MainTab.SelectedIndex = 0; this.selectPrintSendInfopara = 1; return; } } } else { Customer cusModel = visaORM.Customer.OrderByDescending(c => c.FCreateDate).FirstOrDefault(c => c.FPassportNo == txtPassportNo.Text); if (cusModel == null) { MessageBox.Show("找不到该签证"); MainTab.SelectedIndex = 0; this.selectPrintSendInfopara = 1; return; } if (cusModel.FSysSend == false) { MessageBox.Show("请先审批后才可以打印"); MainTab.SelectedIndex = 0; this.selectPrintSendInfopara = 1; return; } } StringBuilder sb = new StringBuilder(); //if (gridMain.SelectedItem == null) //{ // MessageBox.Show("请选择需要打印的数据"); // MainTab.SelectedIndex = 0; // return; //} //else //{ // cusModel = gridMain.SelectedItem as Customer; //} // PrintSendInfoSP.sp_SelectPrintSendInfoDataTable table = (PrintSendInfoSP.sp_SelectPrintSendInfoDataTable)(report.DataSource); // PrintSendInfoSP.sp_SelectPrintSendInfoDataTable table = ((PrintSendInfoSP)(report.DataSource)).sp_SelectPrintSendInfo; int i = 1; List <sp_SelectPrintSendInfo_Result> selectPrintSendInfo; if (this.selectPrintSendInfopara == 1) { if (!string.IsNullOrEmpty(this.txtSendNO.Text)) { report.sp_SelectPrintSendInfoTableAdapter.Fill(report.printSendInfo_SP1.sp_SelectPrintSendInfo, this.txtSendNO.Text); } else { report.sp_SelectPrintSendInfoTableAdapter.Fill(report.printSendInfo_SP1.sp_SelectPrintSendInfo, cbNotPrint.SelectedItem.ToString()); } selectPrintSendInfo = sendCollection.Where(s => s.FSelectItem == true).ToList(); } else { report.sp_SelectPrintSendInfoTableAdapter.Fill(report.printSendInfo_SP1.sp_SelectPrintSendInfo, txtPassportNo.Text); selectPrintSendInfo = visaORM.sp_SelectPrintSendInfo(txtPassportNo.Text).ToList(); this.selectPrintSendInfopara = 1; } Data.PrintSendInfo_SP.sp_SelectPrintSendInfoDataTable table = ((Data.PrintSendInfo_SP)(report.DataSource)).sp_SelectPrintSendInfo; List <Data.PrintSendInfo_SP.sp_SelectPrintSendInfoRow> RowList = new List <Data.PrintSendInfo_SP.sp_SelectPrintSendInfoRow>(); report.printSendInfo_SP1.Clear(); foreach (sp_SelectPrintSendInfo_Result r in selectPrintSendInfo) { //PrintSendInfoSP.sp_SelectPrintSendInfoRow tempRow = row; //if (string.IsNullOrEmpty(r.FQZID)) //{ // MessageBox.Show("请先生成签证号"); // MainTab.SelectedIndex = 0; // this.selectPrintSendInfopara = 1; // return; //} var icao = new GenIcao(); string countryShortName = "CHN"; var CountryShortObj = from c in visaORM.Customer.Where(custom => custom.FID == r.QID) join co in visaORM.TCountry on c.FBirthNationlityPresent equals co.FCountry select co; if (CountryShortObj != null) { TCountry CountryShort = CountryShortObj.FirstOrDefault(); if (CountryShort != null) { countryShortName = CountryShort.Fcountryshort; } } icao.encodeVisa("V", "VNM", countryShortName, r.Name, r.Sex, Convert.ToDateTime(r.BirthDay).ToString("dd/MM/yyyy"), r.PID, r.FQZID, (Convert.ToDateTime(r.PDate)).ToString("dd/MM/yyyy")); string icaoLine1 = icao.getUpperLine(); string icaoLine2 = icao.getLowerLine(); string VIDString = icaoLine1 + "\n" + icaoLine2; string timesDetail = ""; if (r.FTimes == 1) { timesDetail = @"Một lần/Single"; } else { timesDetail = @"Nhiều lần/Multiple"; } table.Addsp_SelectPrintSendInfoRow(true, i, r.Name, Convert.ToDateTime(r.BirthDay).ToString("dd MMM yyyy", new System.Globalization.CultureInfo("en-US")), (DateTime)r.FBirthDay, r.Sex, r.FBirthNationlityEn, r.FBirthNationlityPresentEn, r.PID, r.Work, r.CQJDate, timesDetail, (int)r.Days, (int)r.FTimes, (bool)r.FSysPut, (bool)r.FSysSend, r.FQZID, r.FDSN, VIDString, r.FCreateCompany, r.PrintCount, Convert.ToDateTime(r.DDate).ToString("dd MMM yyyy", new System.Globalization.CultureInfo("en-US")), Convert.ToDateTime(r.PDate).ToString("dd MMM yyyy", new System.Globalization.CultureInfo("en-US")), r.CType, Convert.ToDateTime(r.MDate).ToString("dd MMM yyyy", new System.Globalization.CultureInfo("en-US")), r.IDOrder, r.FSysMemo); i++; //sb.Clear(); //sb.Append("签证人:" + r.Name + "\r\n"); //sb.Append("记录时间:" + DateTime.Now + "\r\n"); //sb.Append("生日:" + Convert.ToDateTime(r.BirthDay).ToString("dd MMM yyyy", new System.Globalization.CultureInfo("en-US")) + "\r\n"); //sb.Append("出境时间:" + Convert.ToDateTime(r.DDate).ToString("dd MMM yyyy", new System.Globalization.CultureInfo("en-US")) + "\r\n"); //sb.Append("回归时间:" + Convert.ToDateTime(r.PDate).ToString("dd MMM yyyy", new System.Globalization.CultureInfo("en-US")) + "\r\n"); //sb.Append("签证码:" + VIDString + "\r\n"); //Log.WriteLog.WriteOperateLog(sb.ToString()); } //foreach (PrintSendInfoSP.sp_SelectPrintSendInfoRow tempRow2 in RowList) //{ // table.Addsp_SelectPrintSendInfoRow(tempRow2); //} //sb.Clear(); //sb.Append("记录时间:" + DateTime.Now + "\r\n"); //sb.Append("审批人:" + cbAuditPerson.SelectedItem.ToString() + "\r\n"); //sb.Append("审批职位:" + cbAuditPosition.SelectedItem.ToString() + "\r\n"); //Log.WriteLog.WriteOperateLog(sb.ToString()); report.xrLabelVID.Width = 950; report.xrLabelMemo.Text = txtMemo.Text; report.xrLabelUserName.Text = cbAuditPerson.SelectedItem.ToString(); report.xrLabelDuty.Text = cbAuditPosition.SelectedItem.ToString(); if (!string.IsNullOrEmpty(datePassportMakeDay.Text)) { report.xrLabelMDate.Text = Convert.ToDateTime(datePassportMakeDay.Text).ToString("dd MMM yyyy", new System.Globalization.CultureInfo("en-US")); } else { report.xrLabelMDate.Text = ""; } report.xrLabelVID.Visible = false; //设置签证码为不可见 //设置位置 SetControlPositionInReport(report, 1); MainPreview.Model = new XtraReportPreviewModel(report); report.CreateDocument(); } } catch (System.Exception ex) { Log.WriteLog.WriteErorrLog(ex); MessageBox.Show(ex.ToString()); } }
private void UpdateListViewWithLocations() { string s = textBox1.Text.Trim(); TCountry tc = null; if (comboBoxCountry.SelectedItem is TCountry) { tc = comboBoxCountry.SelectedItem as TCountry; } listView1.BeginUpdate(); listView1.Items.Clear(); int limit = 100; int added = 0; int lastPart = 0; List <TLocation>[] p = { new List <TLocation>(), new List <TLocation>(), new List <TLocation>() }; foreach (TLocation loc in TLocationDatabase.LocationList) { if ((tc == null || loc.CountryISOCode.Equals(tc.ISOCode)) && (s.Length == 0 || (lastPart = loc.ContainsSubstring(s)) > 0)) { switch (lastPart) { case 1: p[0].Add(loc); break; case 2: p[1].Add(loc); break; default: p[2].Add(loc); break; } added++; } if (added > limit) { break; } } for (int j = 0; j < 3; j++) { foreach (TLocation loc in p[j]) { AddLocationToListView(loc); } p[j].Clear(); } listView1.EndUpdate(); if (added > limit) { labelLimitInfo.Text = string.Format("Number of results limited to {0}", added); labelLimitInfo.ForeColor = Color.DarkRed; } else { labelLimitInfo.Text = string.Format("Number of results: {0}", added); labelLimitInfo.ForeColor = Color.DarkGreen; } }