Exemple #1
0
 private void DoAdd(object sender, EventArgs args)
 {
     this.CurrentPack = new Pack();
     this.CrudOp = CrudState.Create;
     this.InitState();
     this.EditMode();
 }
Exemple #2
0
 public bool Update(Pack p)
 {
     string sql = "update " + this.TableName + " set Name = @p0"; //+ p.Name + "'";
     sql += ", Price = @p1, Membership = @p2 ";
     sql += "where " + this.IdName + " = @p3"; //+ p.Id;
     return ((long) this.DoNonQuery(sql, p.Name, p.Price, p.Membership, p.Id)) > 0;
 }
Exemple #3
0
 public bool ExistsExcept(Pack p)
 {
     string sql = "select count(*) from ";
     sql += "(select * from " + this.TableName + " where " + this.IdName + " != @p0)"; //+ p.Id + "')";
     sql += " a where a.Name = @p1"; //+ p.Name + "'";
     return ((long) this.DoScalar(sql, p.Id, p.Name)) > 0;
 }
Exemple #4
0
        public int InsertAreas(Pack p)
        {
            IList<long> list = p.Areas;
            if(list == null || list.Length == 0)
                return 0;

            int inserted = 0;
            DbModel model = new DbModel("PackArea", null);
            for(int i = 0; i < list.Length; i++)
                inserted += (model.Insert(p.Id, list[i]) ? 1 : 0);
             return inserted;
        }
Exemple #5
0
 public bool Insert(Pack p)
 {
     return this.Insert(null, p.Name, p.Price, p.Membership);
 }
Exemple #6
0
 public IDataReader GetAreas(Pack p)
 {
     string sql = "select a.* from Area a inner join PackArea pa on a.Id = pa.Area ";
     sql += "where pa.Pack = @p0"; //+ p.Id + "'";
     return this.DoReader(sql, p.Id);
 }
Exemple #7
0
 public bool Exists(Pack p)
 {
     string sql = "select count(*) from " + this.TableName;
     sql += " where Name = @p0"; //+ p.Name + "'";
     return ((long) this.DoScalar(sql, p.Name)) > 0;
 }
Exemple #8
0
 public long DeleteAreas(Pack p)
 {
     DbModel model = new DbModel("PackArea", null);
     return model.DeleteBy("Pack", p.Id);
 }
Exemple #9
0
 private void SelectCurrent(object sender, EventArgs args)
 {
     this.CurrentPack = (Pack) this.PacksNodeView.NodeSelection.SelectedNode;
     Pack p = this.CurrentPack;
     this.NameEntry.Text = p.Name;
     this.PaymentSpin.Text = string.Format("{0:f2}", p.Price);
     this.MembershipSpin.Text = string.Format("{0:f2}", p.Membership);
     this.DeleteButton.Sensitive = true;
     this.EditButton.Sensitive = true;
 }
Exemple #10
0
 private Pack GetPackFromUI()
 {
     Pack p = new Pack();
     p.Name = this.NameEntry.Text.Trim();
     p.Price = float.Parse(this.PaymentSpin.Text);
     p.Membership = float.Parse(this.MembershipSpin.Text);
     return p;
 }
Exemple #11
0
        private void FillNodeView()
        {
            NodeStore store = new NodeStore(typeof(Pack));
            PackModel m = new PackModel();
            IDataReader reader = m.GetAll();
            Pack p = null;
            while(reader.Read())
            {
                p = new Pack();
                p.Id = (long) reader["Id"];
                p.Name = (string) reader["Name"];
                p.Price = (float) reader["Price"];
                p.Membership = (float) reader["Membership"];
                p.Areas = new LinkedList<long>();
                store.AddNode(p);
            }

            this.PacksNodeView.NodeStore = store;
            this.PacksNodeView.ShowAll();
        }