private void SetFocus(ControlState state) { if (!IsFocused) { return; } switch (state) { case ControlState.Initial: case ControlState.NumberInput: CardNumberInputTextBox.SelectionStart = CardNumberInputTextBox.Text.Length; CardNumberInputTextBox.Focus(FocusState.Programmatic); break; case ControlState.DateInput: DateTextBox.SelectionStart = DateTextBox.Text.Length; DateTextBox.Focus(FocusState.Programmatic); break; case ControlState.SecurityCodeInput: SecurityCodePasswordBox.Focus(FocusState.Programmatic); break; } }
private void listBox1_SelectedIndexChanged(object sender, EventArgs e) { string _connectionstring = module.constr;// @"Data Source=(local);Initial Catalog=Night Duty;Integrated Security=True"; SqlConnection cn = new SqlConnection(_connectionstring); cn.Open(); string _sql = "(SELECT * FROM [EmpDetails] where Name ='" + listBox1.Text + "')"; SqlCommand _command = new SqlCommand(_sql, cn); dr = _command.ExecuteReader(); if (dr.Read()) { richTextBox1.Text = dr["Name"].ToString(); PfNoTextBox.Text = dr["PfNo"].ToString(); richTextBox12.Text = dr["Desg"].ToString(); richTextBox2.Text = dr["RateofPay"].ToString(); richTextBox3.Text = dr["GradePay"].ToString(); } cn.Close(); string _connectionstring2 = module.constr;// @"Data Source=(local);Initial Catalog=Night Duty;Integrated Security=True"; SqlConnection cn2 = new SqlConnection(_connectionstring2); cn2.Open(); string _sql2 = "(SELECT * FROM [Data] where PfNo='" + PfNoTextBox.Text + "')"; SqlCommand _command2 = new SqlCommand(_sql2, cn2); SqlDataAdapter _adapter = new SqlDataAdapter(_command2); DataTable _table = new DataTable(); _adapter.Fill(_table); dataGridView1.AutoGenerateColumns = true; dataGridView1.DataSource = _table; cn2.Close(); DateTextBox.Focus(); }
private void richTextBox10_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Enter) { DateTextBox.Focus(); } }
private void Window_KeyDown(object sender, KeyEventArgs e) { if (e.Key == Key.Tab) { if (NameTextBox.IsFocused) { DateTextBox.Focus(); } else if (DateTextBox.IsFocused) { PublicDocumentRadioButton.Focus(); } else if (PublicDocumentRadioButton.IsFocused) { HiddenDocumentRadioButton.Focus(); } else if (HiddenDocumentRadioButton.IsFocused) { ContentTextBox.Focus(); } else { NameTextBox.Focus(); } e.Handled = true; } }
protected void OKButton_Click(object sender, EventArgs e) { DateTime valueDate = DateTime.MinValue; int storeId = 0; string transactionType = string.Empty; string partyCode = string.Empty; partyCode = PartyDropDownList.SelectedItem.Value; if (DateTextBox != null) { valueDate = MixERP.Net.Common.Conversion.TryCastDate(DateTextBox.Text); } if (StoreDropDownList.SelectedItem != null) { storeId = MixERP.Net.Common.Conversion.TryCastInteger(StoreDropDownList.SelectedItem.Value); } if (TransactionTypeRadioButtonList.SelectedItem != null) { transactionType = TransactionTypeRadioButtonList.SelectedItem.Value; } if (string.IsNullOrWhiteSpace(partyCode)) { MixERP.Net.BusinessLayer.Helpers.FormHelper.MakeDirty(PartyCodeTextBox); MixERP.Net.BusinessLayer.Helpers.FormHelper.MakeDirty(PartyDropDownList); PartyCodeTextBox.Focus(); return; } if (valueDate.Equals(DateTime.MinValue)) { ErrorLabelTop.Text = Resources.Warnings.InvalidDate; DateTextBox.CssClass = "dirty"; DateTextBox.Focus(); return; } if (this.Book == Common.Models.Transactions.TranBook.Sales) { if (StoreDropDownList.Visible) { if (!MixERP.Net.BusinessLayer.Office.Stores.IsSalesAllowed(storeId)) { ErrorLabelTop.Text = Resources.Warnings.SalesNotAllowedHere; MixERP.Net.BusinessLayer.Helpers.FormHelper.MakeDirty(StoreDropDownList); return; } } if (TransactionTypeRadioButtonList.Visible) { if (transactionType.Equals(Resources.Titles.Credit)) { if (!MixERP.Net.BusinessLayer.Core.Parties.IsCreditAllowed(partyCode)) { ErrorLabelTop.Text = Resources.Warnings.CreditNotAllowed; return; } } } } ModeHiddenField.Value = "Started"; this.SetControlStates(); ItemCodeTextBox.Focus(); }
private void richTextBox9_KeyDown_1(object sender, KeyEventArgs e) { CalcTimeTextBox.Text = ""; if (e.KeyCode == Keys.Enter) { SignOffTextBox.Text = SignOffTextBox.Text.Replace("\n", ""); int i = int.Parse(SignOffTextBox.Text); string kl = SignOffTextBox.Text; int c = i.ToString().Length; PfNoTextBox.Text = PfNoTextBox.Text.Replace("\n", ""); DateTextBox.Text = DateTextBox.Text.Replace("\n", ""); TrainNoTextBox.Text = TrainNoTextBox.Text.Replace("\n", ""); SrcStnTextBox.Text = SrcStnTextBox.Text.Replace("\n", ""); DestStnTextBox.Text = DestStnTextBox.Text.Replace("\n", ""); SignOnTextBox.Text = SignOnTextBox.Text.Replace("\n", ""); SignOffTextBox.Text = SignOffTextBox.Text.Replace("\n", ""); CalcTimeTextBox.Text = CalcTimeTextBox.Text.Replace("\n", ""); { if (c == 1) { kl = kl.PadRight(3, '0'); kl = kl.PadLeft(4, '0'); } if (c == 2) { kl = kl.PadRight(4, '0'); } if (c == 3) { kl = kl.PadLeft(4, '0'); } cat = kl + "H"; } var timeSpan = TimeSpan.ParseExact(cat, @"hhmm\H", CultureInfo.InvariantCulture); string s = timeSpan.ToString(@"hh\:mm"); SignOffTextBox.Text = s.ToString(); TrainNoTextBox.Focus(); } if (e.KeyCode == Keys.Enter) { if ((DateTextBox.Text == "" || DateTextBox.Text == "\n") && (TrainNoTextBox.Text == "" || TrainNoTextBox.Text == "\n") && (SrcStnTextBox.Text == "" || SrcStnTextBox.Text == "\n") && (DestStnTextBox.Text == "" || DestStnTextBox.Text == "\n") && (SignOnTextBox.Text == "" || SignOnTextBox.Text == "\n") && (PfNoTextBox.Text == "" || PfNoTextBox.Text == "\n")) { MessageBox.Show("Please Fill Complete values!"); } else { txtbox5 = DateTime.Parse(DateTextBox.Text); Date1 = txtbox5.ToShortDateString(); TimeSpan StartCmp = new TimeSpan(00, 00, 00); TimeSpan EndCmp = new TimeSpan(12, 00, 00); TimeSpan Endday = new TimeSpan(06, 00, 00); if (TimeSpan.Parse(SignOnTextBox.Text) >= StartCmp && TimeSpan.Parse(SignOnTextBox.Text) <= EndCmp && TimeSpan.Parse(SignOffTextBox.Text) >= StartCmp && TimeSpan.Parse(SignOffTextBox.Text) <= EndCmp) { PfNoTextBox.Text = PfNoTextBox.Text.Replace("\n", ""); DateTextBox.Text = DateTextBox.Text.Replace("\n", ""); TrainNoTextBox.Text = TrainNoTextBox.Text.Replace("\n", ""); SrcStnTextBox.Text = SrcStnTextBox.Text.Replace("\n", ""); DestStnTextBox.Text = DestStnTextBox.Text.Replace("\n", ""); SignOnTextBox.Text = SignOnTextBox.Text.Replace("\n", ""); SignOffTextBox.Text = SignOffTextBox.Text.Replace("\n", ""); if (TimeSpan.Parse(SignOffTextBox.Text) > Endday) { Date2 = DateTextBox.Text; TimeSpan span = TimeSpan.Parse(SignOnTextBox.Text).Subtract(Endday); CalcTimeTextBox.Text = span.ToString("hh\\:mm"); } else { Date2 = DateTextBox.Text; TimeSpan span = TimeSpan.Parse(SignOnTextBox.Text).Subtract(TimeSpan.Parse(SignOffTextBox.Text)); CalcTimeTextBox.Text = span.ToString("hh\\:mm"); } } else if (StartCmp >= TimeSpan.Parse(SignOffTextBox.Text) || TimeSpan.Parse(SignOffTextBox.Text) <= EndCmp) { Date2 = txtbox5.AddDays(1).ToShortDateString(); TimeSpan StartCmp4 = new TimeSpan(13, 00, 00); TimeSpan EndCmp4 = new TimeSpan(22, 00, 00); if (StartCmp4 >= TimeSpan.Parse(SignOnTextBox.Text) || TimeSpan.Parse(SignOnTextBox.Text) <= EndCmp4) { var mintym = "22:00:00"; mindt = Date1 + " " + mintym; starttime = DateTime.Parse(mindt); //startdate TimeSpan span; // EndDate //DateTime starttime = DateTime.Parse(start_date);//startdate if (TimeSpan.Parse(SignOffTextBox.Text) > Endday) { string end_date = Date2 + " " + Endday; DateTime endtime = DateTime.Parse(end_date); //DateTime endtime = DateTime.Parse(end_date); span = endtime.Subtract(starttime); } else { string end_date = Date2 + " " + SignOffTextBox.Text; DateTime endtime = DateTime.Parse(end_date); span = endtime.Subtract(starttime); } CalcTimeTextBox.Text = span.ToString("hh\\:mm"); } else { SignOnTextBox.Text = SignOnTextBox.Text.Replace("\n", ""); start_date = Date1 + " " + SignOnTextBox.Text; starttime = DateTime.Parse(start_date); if (TimeSpan.Parse(SignOffTextBox.Text) > Endday) { string end_date = Date2 + " " + (Endday.ToString());// EndDate DateTime endtime = DateTime.Parse(end_date); TimeSpan span = endtime.Subtract(starttime); CalcTimeTextBox.Text = span.ToString("hh\\:mm"); } else { string end_date = Date2 + " " + SignOffTextBox.Text; // EndDate //DateTime starttime = DateTime.Parse(start_date);//startdate DateTime endtime = DateTime.Parse(end_date); TimeSpan span = endtime.Subtract(starttime); CalcTimeTextBox.Text = span.ToString("hh\\:mm"); } } } else { Date2 = txtbox5.ToShortDateString(); TimeSpan StartCmp4 = new TimeSpan(13, 00, 00); TimeSpan EndCmp4 = new TimeSpan(22, 00, 00); if (StartCmp4 >= TimeSpan.Parse(SignOnTextBox.Text) || TimeSpan.Parse(SignOnTextBox.Text) <= EndCmp4) { var mintym = "22:00:00"; mindt = Date1 + " " + mintym; starttime = DateTime.Parse(mindt); //startdate string end_date = Date2 + " " + SignOffTextBox.Text; // EndDate //DateTime starttime = DateTime.Parse(start_date);//startdate DateTime endtime = DateTime.Parse(end_date); //TimeSpan endtym = TimeSpan.Parse(endtime.ToString()); if (TimeSpan.Parse(SignOffTextBox.Text) <= EndCmp4) { } else { TimeSpan span = endtime.Subtract(starttime); CalcTimeTextBox.Text = span.ToString("hh\\:mm"); } } else { start_date = Date1 + " " + SignOnTextBox.Text; // StartDate starttime = DateTime.Parse(start_date); //startdate string end_date = Date2 + " " + SignOffTextBox.Text; // EndDate DateTime endtime = DateTime.Parse(end_date); TimeSpan span = endtime.Subtract(starttime); CalcTimeTextBox.Text = span.ToString("hh\\:mm"); } } try { PfNoTextBox.Text = PfNoTextBox.Text.Replace("\n", ""); DateTextBox.Text = DateTextBox.Text.Replace("\n", ""); TrainNoTextBox.Text = TrainNoTextBox.Text.Replace("\n", ""); SrcStnTextBox.Text = SrcStnTextBox.Text.Replace("\n", ""); DestStnTextBox.Text = DestStnTextBox.Text.Replace("\n", ""); SignOnTextBox.Text = SignOnTextBox.Text.Replace("\n", ""); SignOffTextBox.Text = SignOffTextBox.Text.Replace("\n", ""); string _connectionstring = module.constr;// @"Data Source=(local);Initial Catalog=Night Duty;Integrated Security=True"; SqlConnection cn = new SqlConnection(_connectionstring); cn.Open(); string sqlins = "insert into Data values (" + PfNoTextBox.Text + ",'" + DateTextBox.Text + "','" + Date2 + "','" + TrainNoTextBox.Text + "','" + SrcStnTextBox.Text + "','" + DestStnTextBox.Text + "','" + SignOnTextBox.Text + "','" + SignOffTextBox.Text + "','" + CalcTimeTextBox.Text + "')"; SqlCommand cmd = new SqlCommand(sqlins, cn); cmd.ExecuteNonQuery(); cn.Close(); cn.Open(); string _sql = "(SELECT * FROM [Data] WHERE PfNo=" + PfNoTextBox.Text + ")"; SqlCommand _command = new SqlCommand(_sql, cn); SqlDataAdapter _adapter = new SqlDataAdapter(_command); DataTable _table = new DataTable(); _adapter.Fill(_table); dataGridView1.AutoGenerateColumns = true; dataGridView1.DataSource = _table; cn.Close(); } catch (Exception ex) { throw ex; } DateTextBox.Focus(); TrainNoTextBox.Text = ""; SrcStnTextBox.Text = ""; DestStnTextBox.Text = ""; SignOnTextBox.Text = ""; SignOffTextBox.Text = ""; SignOffTextBox.Text = ""; DateTextBox.Text = ""; CalcTimeTextBox.Text = ""; } } }
//int Employee; public DailyActivityDetail() { InitializeComponent(); DateTextBox.Focus(); }
private bool CheckingWhetherAllFieldsFilledCorrectly() { if (NameTextBox.Text == defaultDocumentName) { MessageBox.Show("Укажите название документа.", "Ошибка"); NameTextBox.Focus(); return(false); } if (DateTextBox.Text == defaultDocumentDate || DateTextBox.Text == "") { MessageBox.Show("Укажите дату создания документа в формате ДД.ММ.ГГГГ либо нажмите на кнопку 'Cегодня', чтобы задать в качестве даты создания сегодняшний день.", "Ошибка"); DateTextBox.Focus(); return(false); } if (PublicDocumentRadioButton.IsChecked == false && HiddenDocumentRadioButton.IsChecked == false) { MessageBox.Show("Укажите уровень доступности документа.", "Ошибка"); PublicDocumentRadioButton.Focus(); return(false); } if (ContentTextBox.Text == defaultDocumentText) { MessageBox.Show("Документ не может быть пустым.", "Ошибка"); ContentTextBox.Focus(); return(false); } if (_storage.Documents.Items.Count(doc => doc.Name == NameTextBox.Text && doc != _document) > 0) { MessageBox.Show("В системе уже существует документ с таким названием.", "Ошибка"); NameTextBox.Text = ""; NameTextBox.Focus(); return(false); } if (!HelpingMethods.TryParsingTheDate(DateTextBox.Text)) { MessageBox.Show("Дата в полях должна задаваться в формате ДД.ММ.ГГГГ — например: 25.05.2017 . Оформите дату создания документа корректно либо воспользуйтесь кнопкой 'Сегодня', чтобы быстро указать сегодняшний день.", "Ошибка"); DateTextBox.Text = ""; DateTextBox.Focus(); return(false); } if (DateTime.Parse(DateTextBox.Text) > DateTime.Now) { MessageBox.Show("Некорректная дата. Этот день еще не наступил.", "Ошибка"); DateTextBox.Text = ""; DateTextBox.Focus(); return(false); } if (DateTime.Parse(DateTextBox.Text) < DateTime.Parse(foundationStringDate)) { MessageBox.Show("Некорректная дата. В это время нашей компании еще не существовало.", "Ошибка"); DateTextBox.Text = ""; DateTextBox.Focus(); return(false); } if (_document.Id != -1 && DateTime.Parse(DateTextBox.Text) > _document.Versions[0].Date) { MessageBox.Show("Некорректная дата создания документа. К моменту наступления этого дня, некоторые версии уже были зарегистрированы в системе.", "Ошибка"); DateTextBox.Text = ""; DateTextBox.Focus(); return(false); } return(true); }