Example #1
0
    protected void bind_formview(string mode)
    {
        //have to use a collection as formview needs to bind to enumerable
        PlacesTableCollection _tbl = new PlacesTableCollection();

        if (mode != "Insert")
        {
            int         _pid = wwi_func.vint(wwi_security.DecryptString(get_token("pid").ToString(), "publiship"));
            PlacesTable _ct  = new PlacesTable(_pid);
            _tbl.Add(_ct);

            //store original value for country name so we can check against database when saving
            if (this.dxhfOrder.Contains("oldvalue"))
            {
                this.dxhfOrder.Remove("oldvalue");
            }
            this.dxhfOrder.Add("oldvalue", _ct.PlaceName);
        }
        else
        {
            PlacesTable _ct = new PlacesTable();
            _tbl.Add(_ct);
        }

        this.fmvPlace.DataSource = _tbl;
        this.fmvPlace.DataBind();
    }
Example #2
0
    /// <summary>
    /// update Place table
    /// </summary>
    /// <param name="hblid">int</param>
    protected void update_place()
    {
        //voyageid
        int _pid = wwi_func.vint(wwi_security.DecryptString(get_token("pid").ToString(), "publiship"));
        //original value for name
        string _oldvalue = this.dxhfOrder.Contains("oldvalue") ? this.dxhfOrder.Get("oldvalue").ToString() : "";

        if (_pid > 0)
        {
            try
            {
                //new instance of record
                PlacesTable _tbl = new PlacesTable(_pid);

                //get values off insert form
                //check duplicate name
                ASPxTextBox _txt = (ASPxTextBox)this.fmvPlace.FindControl("dxtxtPlaceEdit");
                if (_txt != null && _txt.Text != "")
                {
                    string _newvalue  = _txt.Text.Trim().ToString(); //country name
                    bool   _duplicate = _newvalue != _oldvalue?wwi_func.value_exists("PlaceName", "PlacesTable", _newvalue) : false;

                    if (!_duplicate)
                    {
                        _tbl.PlaceName = _newvalue;
                        //country id
                        ASPxComboBox _cbo = (ASPxComboBox)this.fmvPlace.FindControl("dxcboCountry");
                        if (_cbo != null && _cbo.Text != "")
                        {
                            _tbl.CountryID = wwi_func.vint(_cbo.Value.ToString());
                        }

                        //update
                        _tbl.Save();
                    }
                    else
                    {
                        string _ex = string.Format("{0} is already in database. This record will not be saved", _newvalue);
                        this.dxlblErr.Text          = _ex;
                        this.dxpnlErr.ClientVisible = true;
                    }
                }
            }
            catch (Exception ex)
            {
                string _ex = ex.Message.ToString();
                this.dxlblErr.Text          = _ex;
                this.dxpnlErr.ClientVisible = true;
            }
        }
        else
        {
            string _ex = "Can't update record Country ID = 0";
            this.dxlblErr.Text          = _ex;
            this.dxpnlErr.ClientVisible = true;
        }
    }
Example #3
0
        void LoadTableRows()
        {
            PlacesTable.SetNumberOfRows(ViewModel.Places.Count, "default");

            for (var i = 0; i < ViewModel.Places.Count; i++)
            {
                var placeRow = (PlaceRowController)PlacesTable.GetRowController(i);
                placeRow.RowText = ViewModel.Places[i].Name;
            }

            ShowAnimation(false);
        }
Example #4
0
        public void BindGrid(string sortExpression = "", bool isSort = false)
        {
            using (var db = new AGRODataContext(Server.MapPath("\\")))
            {
                IQueryable <PlaceAndCulture> query = db.Places
                                                     .Join(db.Cultures, p => p.PCulture, c => c.IdC, (p, c) => new PlaceAndCulture {
                    Place = p, Culture = c
                })
                                                     .Join(db.Animals, pc => pc.Place.PAnimals, a => a.IdA, (pc, a) => new PlaceAndCulture {
                    Place = pc.Place, Culture = pc.Culture, Animals = a
                });

                switch (sortExpression)
                {
                case "Pname":
                    query = GetSortExpression(query, pc => pc.Place.Pname, "Pname", isSort);
                    break;

                case "MPrice":
                    query = GetSortExpression(query, pc => pc.Place.MPrice, "MPrice", isSort);
                    break;

                case "PCulture":
                    query = GetSortExpression(query, pc => pc.Culture.Cname, "PCulture", isSort);
                    break;

                case "PAnimals":
                    query = GetSortExpression(query, pc => pc.Animals.AName, "PAnimals", isSort);
                    break;

                default:
                    query = GetSortExpression(query, pc => pc.Place.IdP, "IdP", isSort);
                    break;
                }

                var source = query
                             .Select(x => new
                {
                    Idp        = x.Place.IdP,
                    Pname      = x.Place.Pname,
                    MPrice     = x.Place.MPrice,
                    PCulture   = x.Culture.Cname,
                    PCultuteId = x.Culture.IdC,
                    PAnimals   = x.Animals.AName,
                    PAnimalsId = x.Animals.IdA
                })
                             .ToList();

                PlacesTable.DataSource = source;
                PlacesTable.DataBind();
            }
        }
Example #5
0
    //end update

    /// <summary>
    /// new record
    /// </summary>
    protected int insert_place()
    {
        int _newid = 0;

        try
        {
            ///new instance of record
            PlacesTable _tbl = new PlacesTable();

            //get values off insert form
            //check for duplicate name
            ASPxTextBox _txt = (ASPxTextBox)this.fmvPlace.FindControl("dxtxtPlaceInsert");
            if (_txt != null && _txt.Text != "")
            {
                string _newvalue = _txt.Text.Trim().ToString(); //country name

                if (!wwi_func.value_exists("PlaceName", "PlacesTable", _newvalue))
                {
                    _tbl.PlaceName = _txt.Text.Trim().ToString();

                    //country id
                    ASPxComboBox _cbo = (ASPxComboBox)this.fmvPlace.FindControl("dxcboCountry");
                    if (_cbo != null && _cbo.Text != "")
                    {
                        _tbl.CountryID = wwi_func.vint(_cbo.Value.ToString());
                    }

                    //insert
                    _tbl.Save();
                    //get new id
                    _newid = (int)_tbl.GetPrimaryKeyValue();
                }
                else
                {
                    string _ex = string.Format("{0} is already in database. This record will not be saved", _newvalue);
                    this.dxlblErr.Text          = _ex;
                    this.dxpnlErr.ClientVisible = true;
                }
            }
        }
        catch (Exception ex)
        {
            string _ex = ex.Message.ToString();
            this.dxlblErr.Text          = _ex;
            this.dxpnlErr.ClientVisible = true;
        }

        return(_newid);
    }
	    public void Insert(string PlaceName,int? CountryID,int? DefaultPalletID,byte[] Ts)
	    {
		    PlacesTable item = new PlacesTable();
		    
            item.PlaceName = PlaceName;
            
            item.CountryID = CountryID;
            
            item.DefaultPalletID = DefaultPalletID;
            
            item.Ts = Ts;
            
	    
		    item.Save(UserName);
	    }
        void ReleaseDesignerOutlets()
        {
            if (CoffeeAnimationView != null)
            {
                CoffeeAnimationView.Dispose();
                CoffeeAnimationView = null;
            }

            if (PlacesTable != null)
            {
                PlacesTable.Dispose();
                PlacesTable = null;
            }

            if (ImageGroup != null)
            {
                ImageGroup.Dispose();
                ImageGroup = null;
            }

            if (WarningGroup != null)
            {
                WarningGroup.Dispose();
                WarningGroup = null;
            }

            if (WarningMessageLabel != null)
            {
                WarningMessageLabel.Dispose();
                WarningMessageLabel = null;
            }

            if (TryAgainButton != null)
            {
                TryAgainButton.Dispose();
                TryAgainButton = null;
            }
        }
Example #8
0
    //end update

    /// <summary>
    /// new record
    /// </summary>
    protected int insert_place()
    {
        int _newid = 0;

        try
        {
            ///new instance of record
            PlacesTable _tbl = new PlacesTable();
            
            //get values off insert form
            //check for duplicate name
            ASPxTextBox _txt = (ASPxTextBox)this.fmvPlace.FindControl("dxtxtPlaceInsert");
            if (_txt != null && _txt.Text != "")
            {
                string _newvalue = _txt.Text.Trim().ToString(); //country name

                if (!wwi_func.value_exists("PlaceName", "PlacesTable", _newvalue))
                {
                    _tbl.PlaceName = _txt.Text.Trim().ToString();

                    //country id
                    ASPxComboBox _cbo = (ASPxComboBox)this.fmvPlace.FindControl("dxcboCountry");
                    if (_cbo != null && _cbo.Text != "")
                    {
                        _tbl.CountryID = wwi_func.vint(_cbo.Value.ToString());
                    }

                    //insert
                    _tbl.Save();
                    //get new id
                    _newid = (int)_tbl.GetPrimaryKeyValue();
                }
                else
                {
                    string _ex = string.Format("{0} is already in database. This record will not be saved", _newvalue);
                    this.dxlblErr.Text = _ex;
                    this.dxpnlErr.ClientVisible = true;
                }
            }
        }
        catch (Exception ex)
        {
            string _ex = ex.Message.ToString();
            this.dxlblErr.Text = _ex;
            this.dxpnlErr.ClientVisible = true;
        }

        return _newid;
    }
Example #9
0
    /// <summary>
    /// update Place table
    /// </summary>
    /// <param name="hblid">int</param>
    protected void update_place()
    {
        //voyageid
        int _pid = wwi_func.vint(wwi_security.DecryptString(get_token("pid").ToString(), "publiship"));
        //original value for name
        string _oldvalue = this.dxhfOrder.Contains("oldvalue") ? this.dxhfOrder.Get("oldvalue").ToString() : "";
   
        if (_pid > 0)
        {
            try
            {
                //new instance of record
                PlacesTable _tbl = new PlacesTable(_pid);

                //get values off insert form
                //check duplicate name
                ASPxTextBox _txt = (ASPxTextBox)this.fmvPlace.FindControl("dxtxtPlaceEdit");
                if (_txt != null && _txt.Text != "")
                {  
                    string _newvalue = _txt.Text.Trim().ToString(); //country name
                    bool _duplicate = _newvalue != _oldvalue ? wwi_func.value_exists("PlaceName", "PlacesTable", _newvalue) : false;

                    if (!_duplicate)
                    {
                        _tbl.PlaceName  = _newvalue;
                        //country id
                        ASPxComboBox _cbo = (ASPxComboBox)this.fmvPlace.FindControl("dxcboCountry");
                        if (_cbo != null && _cbo.Text != "")
                        {
                            _tbl.CountryID = wwi_func.vint(_cbo.Value.ToString());
                        }
                        
                        //update
                        _tbl.Save();
                    }
                    else
                    {
                        string _ex = string.Format("{0} is already in database. This record will not be saved", _newvalue);
                        this.dxlblErr.Text = _ex;
                        this.dxpnlErr.ClientVisible = true;
                    }
                }
            }
            catch (Exception ex)
            {
                string _ex = ex.Message.ToString();
                this.dxlblErr.Text = _ex;
                this.dxpnlErr.ClientVisible = true;
            }
        }
        else
        {
            string _ex = "Can't update record Country ID = 0";
            this.dxlblErr.Text = _ex;
            this.dxpnlErr.ClientVisible = true;
        }
    }
Example #10
0
    protected void bind_formview(string mode)
    {
        //have to use a collection as formview needs to bind to enumerable
        PlacesTableCollection _tbl = new PlacesTableCollection();
        if (mode != "Insert")
        {
            int _pid = wwi_func.vint(wwi_security.DecryptString(get_token("pid").ToString(), "publiship"));
            PlacesTable _ct = new PlacesTable(_pid);
            _tbl.Add(_ct);

            //store original value for country name so we can check against database when saving
            if (this.dxhfOrder.Contains("oldvalue")) { this.dxhfOrder.Remove("oldvalue"); }
            this.dxhfOrder.Add("oldvalue", _ct.PlaceName); 
        }
        else
        {
            PlacesTable _ct = new PlacesTable();
            _tbl.Add(_ct);
        }

        this.fmvPlace.DataSource = _tbl;
        this.fmvPlace.DataBind();
    }
	    public void Update(int PlaceID,string PlaceName,int? CountryID,int? DefaultPalletID,byte[] Ts)
	    {
		    PlacesTable item = new PlacesTable();
	        item.MarkOld();
	        item.IsLoaded = true;
		    
			item.PlaceID = PlaceID;
				
			item.PlaceName = PlaceName;
				
			item.CountryID = CountryID;
				
			item.DefaultPalletID = DefaultPalletID;
				
			item.Ts = Ts;
				
	        item.Save(UserName);
	    }