private void LoadData() { ArrayList al = DBLayer.AbonementPriceDynamic.GetList(this.Id); DataTable dt = new DataTable(); dt.Columns.Add("Id", typeof(int)); dt.Columns.Add("Price", typeof(double)); dt.Columns.Add("DateStart", typeof(DateTime)); dt.Columns.Add("DateFinish", typeof(DateTime)); for (int i = 0; i < al.Count; i++) { DBLayer.AbonementPriceDynamic.Details det = (DBLayer.AbonementPriceDynamic.Details)al[i]; DataRow dr = dt.Rows.Add(); dr["Id"] = det.Id; dr["Price"] = det.Price; dr["DateStart"] = det.DateStart; dr["DateFinish"] = det.DateFinish; } grPrices.DataSource = dt; }
public static void Insert(DBLayer.AbonementPriceDynamic.Details det) { string sql = "INSERT INTO AbonementPriceDynamic (AbonementId, Price, [DateStart], [DateFinish]) "; sql += " VALUES (" + det.AbonementId.ToString() + ", " + det.Price.ToString().Replace(",", ".") + ", '" + det.DateStart.ToString("yyyyMMdd") + "', '" + det.DateFinish.ToString("yyyyMMdd") + "')"; ZFort.DB.Execute.ExecuteString_void(sql); }
public static void Update(DBLayer.AbonementPriceDynamic.Details det) { ZFort.DB.Execute.ExecuteString_void("UPDATE AbonementPriceDynamic SET [AbonementId] = " + det.AbonementId.ToString() + " WHERE [Id] = " + det.Id.ToString()); ZFort.DB.Execute.ExecuteString_void("UPDATE AbonementPriceDynamic SET [Price] = " + det.Price.ToString().Replace(",", ".") + " WHERE [Id] = " + det.Id.ToString()); ZFort.DB.Execute.ExecuteString_void("UPDATE AbonementPriceDynamic SET [DateStart] = '" + det.DateStart.ToString("yyyyMMdd") + "' WHERE [Id] = " + det.Id.ToString()); ZFort.DB.Execute.ExecuteString_void("UPDATE AbonementPriceDynamic SET [DateFinish] = '" + det.DateFinish.ToString("yyyyMMdd") + "' WHERE [Id] = " + det.Id.ToString()); }
public FrmEditAbonementPrice(int id) { InitializeComponent(); this.Details = DBLayer.AbonementPriceDynamic.GetDetails(id); this.Id = id; dtpFinish.Value = this.Details.DateFinish; dtpStart.Value = this.Details.DateStart; tbPrice.Text = this.Details.Price.ToString(); }
public static ArrayList GetList(int id) { string sql = "SELECT * FROM AbonementPriceDynamic WHERE AbonementId = " + id.ToString(); DataTable dt = ZFort.DB.Execute.ExecuteString_DataTable(sql); ArrayList al = new ArrayList(); foreach (DataRow dr in dt.Rows) { DBLayer.AbonementPriceDynamic.Details det = new DBLayer.AbonementPriceDynamic.Details(); if (!dr.IsNull("Id")) { det.Id = Convert.ToInt32(dr["Id"]); } if (!dr.IsNull("AbonementId")) { det.AbonementId = Convert.ToInt32(dr["AbonementId"]); } if (!dr.IsNull("Price")) { det.Price = Convert.ToDouble(dr["Price"]); } if (!dr.IsNull("DateStart")) { det.DateStart = Convert.ToDateTime(dr["DateStart"]); } if (!dr.IsNull("DateFinish")) { det.DateFinish = Convert.ToDateTime(dr["DateFinish"]); } al.Add(det); } return(al); }