private void SetData(StationMaster row) { bool isNew = false; if (row.station_id != 0) { // 更新のとき 変更不可 this.station_id.IsEnabled = false; // 削除を有効に this.deleteButton.IsEnabled = true; this.station_id.Text = row.station_id.ToString(); } else { isNew = true; // 新規のとき 変更可 this.station_id.IsEnabled = true; // 削除を無効に this.deleteButton.IsEnabled = false; this.station_id.Text = ""; } this.station_name_en.Text = row.station_name_en; this.station_name_jp.Text = row.station_name_jp; this.station_name_cn.Text = row.station_name_cn; SelectTextBoxNumber(this.station_type, row.station_type, isNew); this.station_section_id.SelectedValue = row.station_section_id; SelectComboByTag(this.station_enable, row.station_enable); SelectTextBoxNumber(this.station_point_id1, row.station_point_id1, isNew); }
/// <summary> /// オーダーIDから発ステーションに変換 /// </summary> /// <param name="value"></param> /// <param name="targetType"></param> /// <param name="parameter"></param> /// <param name="culture"></param> /// <returns></returns> public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { int order_id; string result_value = ""; if (this.GetInt(value, out order_id)) { // order_status_logのorder_log_idの一致する行でorder_log_datetimeが最新の行が対象 OrderStatusLog order_status_log = GetOrderStatusLog(order_id); if (order_status_log != null) { string localeCode = CommonUtil.GetAppLocaleCode(); // ステーション名を取得 string valueFieldName = "station_name_" + localeCode; // result_value = GetValue<string>(StationMaster.SelectNameSql(localeCode, order_status_log.order_log_from_pt.ToString()), valueFieldName); result_value = GetValue <string>(StationMaster.SelectNameByPointSql(localeCode, order_status_log.order_log_from_pt.ToString()), valueFieldName); } } return(result_value); }
public ActionResult DeleteConfirmed(int id) { StationMaster stationMaster = db.StationMasters.Find(id); db.StationMasters.Remove(stationMaster); db.SaveChanges(); return(RedirectToAction("Index")); }
/// <summary> /// The text user name lost keyboard focus. /// </summary> /// <param name="sender"> /// The sender. /// </param> /// <param name="e"> /// The e. /// </param> private async void TextUserNameLostKeyboardFocus( [NotNull] object sender, [NotNull] KeyboardFocusChangedEventArgs e) { if (sender == null) { throw new ArgumentNullException(nameof(sender)); } if (e == null) { throw new ArgumentNullException(nameof(e)); } if (this.TextUserName.Text.Length == 0) { return; } await Task.Factory.StartNew( () => { string text = null; Application.Current.Dispatcher.Invoke( DispatcherPriority.Normal, (ThreadStart)(() => text = this.TextUserName.Text)); if (Regex.IsMatch(text, "^0205")) { var zoneIndex = Convert.ToInt32(text.Substring(4, 2)); var divisionIndex = Convert.ToInt32(text.Substring(6, 2)); var zone = DataHelper.ZoneAndDivisionModel.ZoneList[zoneIndex]; var division = DataHelper.ZoneAndDivisionModel.DivisionList[zone][divisionIndex]; if (StaticDbContext.ConnectFireStore.FindDocument( text, "Root", "Employee", zone, division, "StationMaster")) { this.stationMaster = StaticDbContext.ConnectFireStore.GetCollectionFields <StationMaster>( "Root", "Employee", zone, division, "StationMaster", text); } } Application.Current.Dispatcher.Invoke(() => { this.ButtonLogin.IsEnabled = true; }); }).ConfigureAwait(true); }
/// <summary> /// The button accept on click. /// </summary> /// <param name="sender"> /// The sender. /// </param> /// <param name="e"> /// The e. /// </param> private void ButtonAcceptOnClick(object sender, RoutedEventArgs e) { if (string.IsNullOrWhiteSpace(this.TextBoxStationMasterName.Text) || string.IsNullOrWhiteSpace(this.TextBoxStationMasterEmailId.Text) || string.IsNullOrWhiteSpace(this.PasswordBoxStationMasterPassword.Password) || string.IsNullOrWhiteSpace(this.ComboBoxZoneName.Text) || string.IsNullOrWhiteSpace(this.ComboBoxDivisionName.Text)) { MessageBox.Show("Please fill up all the fields!"); return; } if (!this.TextBoxStationMasterName.Text.Contains(" ")) { if (MessageBox.Show( $"Is \"{this.TextBoxStationMasterName.Text}\" Full Name of the Station Master?", "Confirmation of Full Name", MessageBoxButton.YesNo) == MessageBoxResult.No) { return; } } ButtonProgressAssist.SetIsIndicatorVisible(this.ButtonAccept, true); var stationMaster = new StationMaster { Name = this.TextBoxStationMasterName.Text, EmailId = this.TextBoxStationMasterEmailId.Text, Password = this.PasswordBoxStationMasterPassword.Password, Zone = this.ComboBoxZoneName.Text, Division = this.ComboBoxDivisionName.Text }; var backgroundWorker = new BackgroundWorker(); backgroundWorker.DoWork += (o, args) => { var task = this.AddStationMasterAsync(stationMaster); Task.WaitAll(task); }; backgroundWorker.RunWorkerCompleted += (o, args) => { MessageBox.Show("You have successfully added Station Master" + $"\nName: {this.TextBoxStationMasterName.Text}\nId: {this.stationMasterId}"); ButtonProgressAssist.SetIsIndicatorVisible(this.ButtonAccept, false); }; try { backgroundWorker.RunWorkerAsync(); this.Refresh(); } catch (Exception exception) { MessageBox.Show(exception.Message); } }
/// <summary> /// 着ステーション /// </summary> /// <param name="value"></param> /// <param name="targetType"></param> /// <param name="parameter"></param> /// <param name="culture"></param> /// <returns></returns> public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { if (value is string) { string localeCode = CommonUtil.GetAppLocaleCode(); value = GetValue <string>(StationMaster.SelectNamesSql(localeCode, (string)value), "value"); } return(value); }
public ActionResult Edit([Bind(Include = "StationId,StationName,CreatedDate,IsDeleted")] StationMaster stationMaster) { if (ModelState.IsValid) { db.Entry(stationMaster).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(stationMaster)); }
public ActionResult Create([Bind(Include = "StationId,StationName,CreatedDate,IsDeleted")] StationMaster stationMaster) { if (ModelState.IsValid) { db.StationMasters.Add(stationMaster); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(stationMaster)); }
private void UpdateData() { if (this.comboNames.SelectedValue != null) { int id = int.Parse(this.comboNames.SelectedValue.ToString()); StationMaster row = BaseMasterModel.Find <StationMaster>(this.m_db.Conn, id); SetData(row); } }
// GET: StationMasters/Delete/5 public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } StationMaster stationMaster = db.StationMasters.Find(id); if (stationMaster == null) { return(HttpNotFound()); } return(View(stationMaster)); }
/// <summary> /// カンマ区切りのポイント一覧からステーション名一覧をカンマ区切りで取得 /// ステーションはtype2を優先 /// </summary> /// <param name="localeCode"></param> /// <param name="ids"></param> /// <returns></returns> protected string GetStationNamesByPointsPriorityType2(string localeCode, string ids_string) { string value = ""; List <string> names = new List <string>(); string[] ids = ids_string.Split(','); foreach (string id in ids) { // ステーション名を取得 string valueFieldName = "station_name_" + localeCode; string name = this.GetValue <string>(StationMaster.SelectNameByPointSqlPriorityType2(localeCode, id), valueFieldName); if (name != null && name != "") { names.Add(name); } } value = string.Join(",", names); return(value); }
/// <summary> /// 登録または更新ようにコントロールの値を行にを設定 /// </summary> /// <typeparam name="T"></typeparam> /// <param name="row"></param> /// <param name="id"></param> protected override bool SetRowData(object t_row, int id) { bool bRet = true; StationMaster row = (StationMaster)t_row; row.station_id = id; row.station_name_en = this.station_name_en.Text; row.station_name_jp = this.station_name_jp.Text; row.station_name_cn = this.station_name_cn.Text; row.station_enable = (Int16)GetComboSelectedTagValue(this.station_enable, 0); row.station_section_id = GetComboSelectedValueAsInt(this.station_section_id); int station_type; if (IsValidInt(this.station_type.Text, Properties.Resources.STATION_TYPE, out station_type)) { row.station_type = (Int16)station_type; } else { bRet = false; } int station_point_id1; if (IsValidInt(this.station_point_id1.Text, Properties.Resources.STATION_POINT_ID1, out station_point_id1)) { row.station_point_id1 = station_point_id1; } else { bRet = false; } return(bRet); }
/// <summary> /// The background worker do work. /// </summary> /// <param name="sender"> /// The sender. /// </param> /// <param name="e"> /// The e. /// </param> private async void BackgroundWorkerDoWork(object sender, DoWorkEventArgs e) { var stationMasterName = string.Empty; var zone = string.Empty; var division = string.Empty; this.Dispatcher.Invoke( () => { ButtonProgressAssist.SetIsIndicatorVisible(this.ButtonAccept, true); stationMasterName = this.TextBoxStationMasterName.Text; zone = this.ComboBoxZoneName.Text; division = this.ComboBoxDivisionName.Text; }, DispatcherPriority.Normal); var id = StaticDbContext.ConnectFireStore.GetAllDocumentId( "Root", "Employee", zone, division, "StationMaster"); var max = 0; if (id.Count != 0) { max = Convert.ToInt32(id.OrderByDescending(i => int.Parse(i.Substring(8))).First().Substring(8)); } this.stationMasterId = $"{(int)EnumEmployeeGroups.GroupB:D2}" + $"{(int)EnumEmployeeType.StationMaster:D2}" + $"{DataHelper.ZoneAndDivisionModel.ZoneList.IndexOf(zone):D2}" + $"{DataHelper.ZoneAndDivisionModel.DivisionList[zone].IndexOf(division):D2}" + $"{(max + 1):D7}"; var stationMaster = new StationMaster { Name = stationMasterName, Id = this.stationMasterId }; var noOfStationMaster = 0; var divisionField = StaticDbContext.ConnectFireStore.GetCollectionFields("Root", "Employee", zone, division); if (divisionField != null) { noOfStationMaster = Convert.ToInt32(divisionField["noOfStationMaster"]); } noOfStationMaster++; await StaticDbContext.ConnectFireStore.AddOrUpdateCollectionDataAsync( new Dictionary <string, int> { { "noOfStationMaster", noOfStationMaster } }, "Root", "Employee", zone, division); await StaticDbContext.ConnectFireStore.AddOrUpdateCollectionDataAsync( stationMaster, "Root", "Employee", zone, division, "StationMaster", stationMaster.Id); }
protected override void SetID(object t_row, int id) { StationMaster row = (StationMaster)t_row; row.station_id = id; }
/// <summary> /// The add station master async. /// </summary> /// <param name="stationMaster"> /// The station master. /// </param> /// <returns> /// The <see cref="Task"/>. /// </returns> private async Task AddStationMasterAsync(StationMaster stationMaster) { var id = StaticDbContext.ConnectFireStore.GetAllDocumentId( "Root", "Employee", stationMaster.Zone, stationMaster.Division, "StationMaster"); var max = 0; if (id.Count != 0) { max = Convert.ToInt32(id.OrderByDescending(i => int.Parse(i.Substring(8))).First().Substring(8)); } this.stationMasterId = $"{(int)EnumEmployeeGroups.GroupB:D2}" + $"{(int)EnumEmployeeType.StationMaster:D2}" + $"{DataHelper.ZoneAndDivisionModel.ZoneList.IndexOf(stationMaster.Zone):D2}" + $"{DataHelper.ZoneAndDivisionModel.DivisionList[stationMaster.Zone].IndexOf(stationMaster.Division):D2}" + $"{(max + 1):D7}"; stationMaster.Id = this.stationMasterId; var noOfStationMaster = 0; var divisionField = StaticDbContext.ConnectFireStore.GetCollectionFields( "Root", "Employee", stationMaster.Zone, stationMaster.Division); if (divisionField != null) { noOfStationMaster = Convert.ToInt32(divisionField["noOfStationMaster"]); } if (StaticDbContext.ConnectFireStore?.FindDocument( stationMaster.Id, "Root", "Employee", stationMaster.Zone, stationMaster.Division, "StationMaster") == false) { noOfStationMaster++; } await StaticDbContext.ConnectFireStore.AddOrUpdateCollectionDataAsync( new Dictionary <string, int> { { "noOfStationMaster", noOfStationMaster } }, "Root", "Employee", stationMaster.Zone, stationMaster.Division); await StaticDbContext.ConnectFireStore.AddOrUpdateCollectionDataAsync( stationMaster, "Root", "Employee", stationMaster.Zone, stationMaster.Division, "StationMaster", stationMaster.Id); }