private void deleteRestrictionButton_Click(object sender, EventArgs e) { DialogResult dialogResult = MessageBox.Show("آیا از حذف مطمئن هستید؟", "هشدار", MessageBoxButtons.YesNo, MessageBoxIcon.Warning); if (dialogResult == DialogResult.Yes) { try { selectedRow = validationDataGridView.CurrentCell.RowIndex; SqlManipulator sql = new SqlManipulator(); DataGridViewRow newDataRow = validationDataGridView.Rows[selectedRow]; validationTable deletedRestriction = new validationTable(); deletedRestriction.City = (long)newDataRow.Cells[2].Value; deletedRestriction.startDate = (long)newDataRow.Cells[3].Value; deletedRestriction.enDate = (long)newDataRow.Cells[4].Value; deletedRestriction.id = (long)newDataRow.Cells[0].Value; deletedRestriction.description = (String)newDataRow.Cells[1].Value; sql.removeRestriction(deletedRestriction); var data = sql.getValidationData(); makeValidationTable(data); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } } }
public Boolean removeRestriction(validationTable restriction) { try { ValidationDataClassesDataContext db = new ValidationDataClassesDataContext(cn); var q = from a in db.validationTables where a.id == restriction.id select a; foreach (var a in q) { db.validationTables.DeleteOnSubmit(a); } db.SubmitChanges(); return(true); } catch (Exception ex) { MessageBox.Show(ex.Message); return(false); } }
public List <string> addValidation(validationTable newRestriction) { try { ValidationDataClassesDataContext db = new ValidationDataClassesDataContext(cn); db.validationTables.InsertOnSubmit(newRestriction); db.SubmitChanges(); List <string> report = new List <string>(); report.Add(newRestriction.description + "" + " با موفقیت اضافه گردید"); return(report); } catch (System.Data.SqlClient.SqlException) { // DaftarModelDataContext db = new DaftarModelDataContext(cn); List <string> report = new List <string>(); report.Add("خطا در اضافه کردن محدودیت"); return(report); } }
private void addRestriction() { try { validationTable valid = new validationTable(); DateTime endTime = endDateTimePickerX1.SelectedDateInDateTime; StartEndMonthClass date = new StartEndMonthClass(); date.endDate = Convert.ToInt64(endTime.ToFa("yyyyMMdd")); valid.startDate = startendDate.min; valid.enDate = date.endDate; valid.City = Convert.ToInt64(validCityComboBox.SelectedValue); SqlManipulator sql = new SqlManipulator(); //if (this.lockAllCitiesCheckBox.Checked == true) //{ // var cities = sql.getDataCity(); // foreach(var city in cities) // { // } //} var cityName = sql.getCityName(valid.City); FarsiDateUtil startDate = new FarsiDateUtil(startendDate.min.ToString()); FarsiDateUtil endDate = new FarsiDateUtil(date.endDate.ToString()); valid.description = "قفل" + " " + cityName + " " + endDate.MonthName + endDate.Year; Reporter rpt = new Reporter(sql.addValidation(valid), (int)errorImages.info); rpt.Show(); makeValidationTable(sql.getValidationData()); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
public void addPRVMonthToRestrictedArea(Int64 city, string testDate) { try { Utility utl = new Utility(); validationTable newRestriction = new validationTable(); newRestriction.startDate = findMaxminMonthDay(0).min; newRestriction.enDate = Convert.ToInt64(utl.getPrvMonthLastDay(testDate)); newRestriction.City = city; string cityName = getCityName(newRestriction.City); string message = cityName + " " + " تاریخ " + newRestriction.enDate; newRestriction.description = message; MessageBox.Show(message); ///addValidation(newRestriction); } catch (System.Data.SqlClient.SqlException) { // DaftarModelDataContext db = new DaftarModelDataContext(cn); List <string> report = new List <string>(); report.Add("خطا در اضافه کردن محدودیت"); return; } }
partial void DeletevalidationTable(validationTable instance);
partial void UpdatevalidationTable(validationTable instance);
partial void InsertvalidationTable(validationTable instance);