private void AddAppointment_Load(object sender, EventArgs e) { DefaultSettingsRepository repo = new DefaultSettingsRepository(); radCheckedDropDownList1.DataSource = repo.GetSetingsByType("price").ToList(); radCheckedDropDownList1.DisplayMember = "Name"; radCheckedDropDownList1.ValueMember = "Value"; bSave.DialogResult = DialogResult.OK; bCancel.DialogResult = DialogResult.Cancel; PersianDateFormatter pdf = new PersianDateFormatter(); tTime.Format = DateTimePickerFormat.Custom; tTime.CustomFormat = "HH:mm"; tTime.ShowUpDown = true; tDate.Text = pdf.getDateString(DateTime.Now); }
private void radGridView2_UserDeletingRow(object sender, Telerik.WinControls.UI.GridViewRowCancelEventArgs e) { DialogResult result = MessageBox.Show("آیا از عملیات حذف مطمئن هستید؟", "هشدار", MessageBoxButtons.YesNo); if (result == DialogResult.No) { e.Cancel = true; } else { DefaultSettingsRepository repo = new DefaultSettingsRepository(); string name = radGridView2.SelectedRows[0].Cells[1].Value.ToString(); repo.delete(name); DefaultSettingsRepository repo2 = new DefaultSettingsRepository(); radGridView2.DataSource = repo2.GetSetingsByType("price").ToList(); } }
private void timer1_Tick(object sender, EventArgs e) { PersianDateFormatter pdf = new PersianDateFormatter(); int date = pdf.convert(toolStripTextBox1.Text); OtherRepository otherRepository = new OtherRepository(); radGridView1.DataSource = otherRepository.getCustomerJoinContract(date); ///////////////////////////////////////////////// DefaultSettingsRepository dRepo = new DefaultSettingsRepository(); DefaultSetting gsmPort = dRepo.GetSetting("gsm_port"); DefaultSetting lastSend = dRepo.GetSetting("last_send"); if (lastSend == null) { DefaultSetting ls = new DefaultSetting(); ls.Value = "13000101"; ls.Name = "last_send"; dRepo.AddSettings(ls); } else { int lastSendInt = Convert.ToInt32(lastSend.Value); int todayInt = pdf.getDateInteger(DateTime.Now); int x = 0; if (todayInt <= lastSendInt) { return; } } if (gsmPort != null) { if (gsmPort.Value != "NULL") { try { GsmCommMain comm = new GsmCommMain(gsmPort.Value, 9600, 150); comm.Open(); byte dcs = (byte)DataCodingScheme.GeneralCoding.Alpha16Bit; DefaultSetting sendTime = dRepo.GetSetting("send_message_time"); DefaultSetting days = dRepo.GetSetting("days_before_send"); DefaultSetting text = dRepo.GetSetting("message_text"); int daysInteger = Convert.ToInt32(days.Value); TimeSpan ts = TimeSpan.Parse(sendTime.Value); TimeSpan nts = DateTime.Now.TimeOfDay; TimeSpan fivemin = TimeSpan.FromMinutes(5); if (nts.CompareTo(ts) >= 0) { if (nts.Subtract(ts).CompareTo(fivemin) > 0) { return; } } else { if (ts.Subtract(nts).CompareTo(fivemin) > 0) { return; } } DateTime dt = DateTime.Now; dt = dt.AddDays(daysInteger); string dateString = pdf.getDateString(dt); object customers = otherRepository.getCustomerJoinContract(dt); IEnumerable<object> collection = (IEnumerable<object>)customers; foreach (object item in collection) { var nameOfProperty = "PhoneNumber"; var propertyInfo = item.GetType().GetProperty(nameOfProperty); var phoneNumber = propertyInfo.GetValue(item, null); var nameOfProperty2 = "Time"; var propertyInfo2 = item.GetType().GetProperty(nameOfProperty2); var time = propertyInfo2.GetValue(item, null); string timeString = time.ToString(); timeString = timeString.Remove(timeString.Length-3); string smsText = text.Value + Environment.NewLine + dateString + Environment.NewLine + timeString; SmsSubmitPdu pdu = new SmsSubmitPdu(smsText, phoneNumber.ToString(), dcs); comm.SendMessage(pdu); } DefaultSettingsRepository dRepo2 = new DefaultSettingsRepository(); DefaultSetting lsls = dRepo2.GetSetting("last_send"); lsls.Value = pdf.getDateInteger(DateTime.Now).ToString(); dRepo2.UpdateSetting(lsls); } catch (Exception ex) { } } } }
private void radGridView2_CellClick(object sender, Telerik.WinControls.UI.GridViewCellEventArgs e) { DefaultSettingsRepository repo = new DefaultSettingsRepository(); string name = radGridView2.SelectedRows[0].Cells[1].Value.ToString(); DefaultSetting ds = repo.GetSetting(name); tMahalDarman.Text = ds.Name; tPrice.Text = ds.Value; }
private void DefaultSettingsForm_Load(object sender, EventArgs e) { DefaultSettingsRepository repo2 = new DefaultSettingsRepository(); radGridView2.DataSource = repo2.GetSetingsByType("price").ToList(); ((GridTableElement)radGridView2.TableElement).AlternatingRowColor = Color.FromArgb(215, 234, 124); radGridView2.TableElement.RowHeight = 35; }
private void bSave_Click(object sender, EventArgs e) { DefaultSettingsRepository repo = new DefaultSettingsRepository(); DefaultSetting ds = new DefaultSetting(); ds.Name = tMahalDarman.Text; ds.Value = tPrice.Text; ds.Type = "price"; DefaultSetting dsDB = repo.GetSetting(tMahalDarman.Text); if (dsDB == null) { repo.AddSettings(ds); } else { dsDB.Name = tMahalDarman.Text; dsDB.Value = tPrice.Text; dsDB.Type = "price"; repo.UpdateSetting(dsDB); } DefaultSettingsRepository repo2 = new DefaultSettingsRepository(); radGridView2.DataSource = repo2.GetSetingsByType("price").ToList(); }
private void radGridView3_UserDeletingRow(object sender, GridViewRowCancelEventArgs e) { DialogResult result = MessageBox.Show("آیا از عملیات حذف مطمئن هستید؟", "هشدار", MessageBoxButtons.YesNo); if (result == DialogResult.No) { e.Cancel = true; } else { int value = 0; DefaultSettingsRepository dRepo = new DefaultSettingsRepository(); ContractRepository cRepo = new ContractRepository(); AppointmentRepository rep = new AppointmentRepository(); int appointmentId = Convert.ToInt32(radGridView3.SelectedRows[0].Cells[0].Value.ToString()); Appointment appo = rep.getAppointment(appointmentId); string[] parts = appo.Description.Split('/'); foreach (string part in parts) { DefaultSetting ds = dRepo.GetSetting(part); value += Convert.ToInt32(ds.Value); } Contract contract = cRepo.getContract(appo.ContractId.Value); contract.ContractPayment -= value; cRepo.updateContract(contract); rep.deleteAppointment(appointmentId); ContractRepository repository = new ContractRepository(); radGridView1.DataSource = repository.getContractsByCustomerId(customerId).ToList(); } }
private void EditAppointmentForm_Load(object sender, EventArgs e) { DefaultSettingsRepository dRepo = new DefaultSettingsRepository(); radCheckedDropDownList1.DataSource = dRepo.GetSetingsByType("price").ToList(); radCheckedDropDownList1.DisplayMember = "Name"; radCheckedDropDownList1.ValueMember = "Value"; PersianDateFormatter pdf = new PersianDateFormatter(); tTime.Format = DateTimePickerFormat.Custom; tTime.CustomFormat = "HH:mm"; tTime.ShowUpDown = true; bSave.DialogResult = DialogResult.OK; bCancel.DialogResult = DialogResult.Cancel; AppointmentRepository repo = new AppointmentRepository(); Appointment appo = repo.getAppointment(appointmentId); DateTime dt = new DateTime(2000, 1, 1, 0, 0, 0).Add(appo.AppointmentTime.Value); tTime.Value = dt; tDate.Text = pdf.convert(appo.AppointmentDate.Value); string[] parts = appo.Description.Split('/'); foreach (RadCheckedListDataItem item in radCheckedDropDownList1.Items) { if (parts.Contains(item.DisplayValue.ToString())) { item.Checked = true; unchangedValue += Convert.ToInt32(item.Value.ToString()); } } }