/// <summary>Returns a string that represents the current object.</summary> public override string ToString() { return($"{RecordType} from {Source} from ${DateFrom?.ToString("d") ?? "unknown"} to {DateTo?.ToString("d" ?? "unknown")}"); }
public string AddSchedule(string Municipality, string TaxType, string Date) { string MunID, TaxID; DateTime DateFrom, DateTo; if (!DateTime.TryParse(Date, out DateFrom)) { return("Date value invalid"); } switch (TaxType.ToLower()) { case "yearly": DateTo = DateFrom.AddYears(1); break; case "monthly": DateTo = DateFrom.AddMonths(1); break; case "weekly": DateTo = DateFrom.AddDays(7); break; case "daily": DateTo = DateFrom; break; default: return("Tax Type parameter invalid"); } SqlConnection conn = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["Connectas"].ConnectionString); try { conn.Open(); DataSet ds = new DataSet(); SqlDataAdapter konektas = new SqlDataAdapter("Select ID from Municipality where [MunicipalityName] = '" + Municipality + "'", conn); konektas.Fill(ds); konektas.Dispose(); if (ds.Tables[0].Rows.Count == 0) { return("Municipality not defined"); } MunID = ds.Tables[0].Rows[0]["ID"].ToString(); ds = new DataSet(); konektas = new SqlDataAdapter("Select ID from TaxesConfig where [TaxTypeString] = '" + TaxType + "'", conn); konektas.Fill(ds); konektas.Dispose(); if (ds.Tables[0].Rows.Count == 0) { return("TaxesConfig not defined"); } TaxID = ds.Tables[0].Rows[0]["ID"].ToString(); SqlCommand cmd = new SqlCommand("INSERT INTO [Taxes] values (" + MunID + "," + TaxID + ",'" + DateFrom.ToString("yyyy-MM-dd") + "','" + DateTo.ToString("yyyy-MM-dd") + "')", conn); cmd.ExecuteNonQuery(); conn.Close(); return("Schedule Added"); } catch (Exception ex) { return(ex.Message); } }
private string GetValueForCellPeriodDate() { var dateFormat = new GetDateFormat().GetDateFormaDotNetById(DateFormatId); //value = DateTime.Parse(value).ToString(dateFormat, ); var valueForPeriodCell = "Period: " + DateFrom.ToString(dateFormat, CultureInfo.InvariantCulture) + " - " + DateTo.ToString(dateFormat, CultureInfo.InvariantCulture); return(valueForPeriodCell); }
public override string ToString() { return("ID: " + ID + "\tFrom: " + DateFrom.ToString() + "\tTo: " + DateTo.ToString() + "\tTime Span: " + timeSpan.ToString() + "\tTitle: " + Title); }
public override string ToString() { return(string.Format("{0}-{1} {2}% rate in {3} (Id {4}), Type {5}", DateFrom.ToString("yyyy.MM.dd"), DateTo.ToString("yyyy.MM.dd"), Rate, MunicipalityName, MunicipalityId, Type)); }