public void Insert(string CompanyName,bool? Customer,string Address1,string Address2,string Address3,string PostCode,int? CountryID,string TelNo,string FaxNo,string MainEmail,int? TypeID,bool? Consignee,bool? Insurance,bool? SalesModule,bool? Exporter,string VATNumber,string DefermentNumber,DateTime? DateRecordAdded,int? RecordAddedBY,int? SalesBy,string PalletDims,int? MaxPalletWeight,int? MaxPalletHeight,string SpecialDeliveryInstructions,int? PricerGroup,byte[] Ts)
	    {
		    NameAndAddressBook item = new NameAndAddressBook();
		    
            item.CompanyName = CompanyName;
            
            item.Customer = Customer;
            
            item.Address1 = Address1;
            
            item.Address2 = Address2;
            
            item.Address3 = Address3;
            
            item.PostCode = PostCode;
            
            item.CountryID = CountryID;
            
            item.TelNo = TelNo;
            
            item.FaxNo = FaxNo;
            
            item.MainEmail = MainEmail;
            
            item.TypeID = TypeID;
            
            item.Consignee = Consignee;
            
            item.Insurance = Insurance;
            
            item.SalesModule = SalesModule;
            
            item.Exporter = Exporter;
            
            item.VATNumber = VATNumber;
            
            item.DefermentNumber = DefermentNumber;
            
            item.DateRecordAdded = DateRecordAdded;
            
            item.RecordAddedBY = RecordAddedBY;
            
            item.SalesBy = SalesBy;
            
            item.PalletDims = PalletDims;
            
            item.MaxPalletWeight = MaxPalletWeight;
            
            item.MaxPalletHeight = MaxPalletHeight;
            
            item.SpecialDeliveryInstructions = SpecialDeliveryInstructions;
            
            item.PricerGroup = PricerGroup;
            
            item.Ts = Ts;
            
	    
		    item.Save(UserName);
	    }
Exemplo n.º 2
0
    protected void fmvAddressBook_DataBound(object sender, EventArgs e)
    {
        //lookup values for country and company type
        NameAndAddressBook _row = (NameAndAddressBook)this.fmvAddressBook.DataItem;

        if (this.fmvAddressBook.CurrentMode == FormViewMode.ReadOnly)
        {
            ASPxLabel _lbl = (ASPxLabel)this.fmvAddressBook.FindControl("dxlblitemCountryID");
            if (_lbl != null)
            {
                int?_country = _row.CountryID != null ? _row.CountryID : 0;
                _lbl.Text = wwi_func.lookup_value("CountryName", "CountryTable", "CountryID", _country);
            }

            _lbl = (ASPxLabel)this.fmvAddressBook.FindControl("dxlblitemTypeID");
            if (_lbl != null)
            {
                int?_type = _row.TypeID != null ? _row.TypeID : 0;
                _lbl.Text = wwi_func.lookup_value("TypeName", "TypeTable", "TypeID", _type);
            }

            //bind contacts grid
            if (_row != null)
            {
                bind_contacts(_row.CompanyID);
            }
        }
        else
        {
            //dlls
            bind_country();
            bind_company_type();
            //if a type id ahs been passed
            string _type = get_token("type");
            if (!string.IsNullOrEmpty(_type))
            {
                //insert mode modify label text
                ASPxLabel _dxlbl = (ASPxLabel)this.fmvAddressBook.FindControl("dxlblinsertCompanyID");
                if (_dxlbl != null)
                {
                    _dxlbl.Text = "New " + _type;
                }
                //set company type
                ASPxComboBox _dxcboType = (ASPxComboBox)this.fmvAddressBook.FindControl("dxcboCompanyType");
                if (_dxcboType != null)
                {
                    _dxcboType.SelectedItem = _dxcboType.Items.FindByText(_type);
                }
            }
        }
    }
Exemplo n.º 3
0
    //end formview inserting
    /// <summary>
    /// by binding in code behind we can avoid objectdatasource not updating nullable values correctly
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void update_company()
    {
        int _pid = wwi_func.vint(wwi_security.DecryptString(get_token("pid").ToString(), "publiship"));
        int? _intnull = null;

        if (_pid > 0)
        {
            try
            {
                //ASPxLabel _lb = (ASPxLabel)_f.FindControl("dxlblCompanyID");
                //if (_lb != null) { _id = _lb.Text.ToString(); }

                NameAndAddressBook _n = new NameAndAddressBook(_pid);

                ASPxTextBox _tx = (ASPxTextBox)this.fmvAddressBook.FindControl("dxtxtName");
                if (_tx != null) { _n.CompanyName = _tx.Text != null ? _tx.Text.ToString() : ""; }

                _tx = (ASPxTextBox)this.fmvAddressBook.FindControl("dxtxtAddress1");
                if (_tx != null) { _n.Address1 = _tx.Text != null ? _tx.Text.ToString() : ""; }

                _tx = (ASPxTextBox)this.fmvAddressBook.FindControl("dxtxtAddress2");
                if (_tx != null) { _n.Address2 = _tx.Text != null ? _tx.Text.ToString() : ""; }

                _tx = (ASPxTextBox)this.fmvAddressBook.FindControl("dxtxtAddress3");
                if (_tx != null) { _n.Address3 = _tx.Text != null ? _tx.Text.ToString() : ""; }

                ASPxComboBox _cb = (ASPxComboBox)this.fmvAddressBook.FindControl("dxcboCountry");
                if (_cb != null) { _n.CountryID = wwi_func.vint(_cb.Value.ToString()); }

                _tx = (ASPxTextBox)this.fmvAddressBook.FindControl("dxtxtPostCode");
                if (_tx != null) { _n.PostCode = _tx.Text != null ? _tx.Text.ToString() : ""; }

                _tx = (ASPxTextBox)this.fmvAddressBook.FindControl("dxtxtTelNo");
                if (_tx != null) { _n.TelNo = _tx.Text != null ? _tx.Text.ToString() : ""; }

                _tx = (ASPxTextBox)this.fmvAddressBook.FindControl("dxtxtFax");
                if (_tx != null) { _n.FaxNo = _tx.Text != null ? _tx.Text.ToString() : ""; }

                _tx = (ASPxTextBox)this.fmvAddressBook.FindControl("dxtxtEmail");
                if (_tx != null) { _n.MainEmail = _tx.Text != null ? _tx.Text.ToString() : ""; }

                _cb = (ASPxComboBox)this.fmvAddressBook.FindControl("dxcboCompanyType");
                if (_cb != null) { _n.TypeID = _cb.Value != null ? wwi_func.vint(_cb.Value.ToString()) : _intnull; }

                ASPxMemo _m = (ASPxMemo)this.fmvAddressBook.FindControl("dxmemoDelivery");
                if (_m != null) { _n.SpecialDeliveryInstructions = _m.Text != null ? _m.Text.ToString() : ""; }

                _tx = (ASPxTextBox)this.fmvAddressBook.FindControl("dxtxtPalletSpec");
                if (_tx != null) { _n.PalletDims = _tx.Text != null ? _tx.Text.ToString() : ""; }

                _tx = (ASPxTextBox)this.fmvAddressBook.FindControl("dxtxtMaxWeight"); //check for nullable int
                if (_tx != null)
                {
                    int? _v = 0;
                    if (!string.IsNullOrEmpty(_tx.Text.ToString())) { _v = wwi_func.vint(_tx.Text.ToString()); }
                    _n.MaxPalletWeight = _v;
                }

                _tx = (ASPxTextBox)this.fmvAddressBook.FindControl("dxtxtMaxHeight"); //check for nullable int
                if (_tx != null)
                {
                    int? _v = 0;
                    if (!string.IsNullOrEmpty(_tx.Text.ToString())) { _v = wwi_func.vint(_tx.Text.ToString()); }
                    _n.MaxPalletHeight = _v;
                }

                ASPxCheckBox _ck = (ASPxCheckBox)this.fmvAddressBook.FindControl("dxckExporter");
                if (_ck != null) { _n.Exporter = _ck.Checked; }

                _ck = (ASPxCheckBox)this.fmvAddressBook.FindControl("dxckCustomer");
                if (_ck != null) { _n.Customer = _ck.Checked; }

                _ck = (ASPxCheckBox)this.fmvAddressBook.FindControl("dxckConsignee");
                if (_ck != null) { _n.Consignee = _ck.Checked; }

                _ck = (ASPxCheckBox)this.fmvAddressBook.FindControl("dxckInsurance");
                if (_ck != null) { _n.Insurance = _ck.Checked; }

                _ck = (ASPxCheckBox)this.fmvAddressBook.FindControl("dxckSalesTarget");
                if (_ck != null) { _n.SalesModule = _ck.Checked; }

                _n.Save();

                //end formview updating
            }
            catch(Exception ex)
            {
                string _ex = ex.Message.ToString();
                this.dxlblErr.Text = _ex;
                this.dxpnlErr.ClientVisible = true;
            }
        }
        else
        {
            string _ex = "Can't update record Comapny ID = 0";
            this.dxlblErr.Text = _ex;
            this.dxpnlErr.ClientVisible = true;
        }
    }
Exemplo n.º 4
0
    }//end menu names loop

    #endregion

    #region company crud operations
    protected int insert_company()
    {
        int _user = Page.Session["user"] != null ? (int)((UserClass)Page.Session["user"]).UserId : 0;
        int? _intnull = null;
        int _newid = 0;

        try
        {
            NameAndAddressBook _n = new NameAndAddressBook();
            _n.DateRecordAdded = DateTime.Now;
            _n.RecordAddedBY = _user;

            ASPxTextBox _tx = (ASPxTextBox)this.fmvAddressBook.FindControl("dxtxtNameInsert");
            if (_tx != null) { _n.CompanyName = _tx.Text != null ? _tx.Text.ToString() : ""; }

            _tx = (ASPxTextBox)this.fmvAddressBook.FindControl("dxtxtAddress1Insert");
            if (_tx != null) { _n.Address1 = _tx.Text != null ? _tx.Text.ToString() : ""; }

            _tx = (ASPxTextBox)this.fmvAddressBook.FindControl("dxtxtAddress2Insert");
            if (_tx != null) { _n.Address2 = _tx.Text != null ? _tx.Text.ToString() : ""; }

            _tx = (ASPxTextBox)this.fmvAddressBook.FindControl("dxtxtAddress3Insert");
            if (_tx != null) { _n.Address3 = _tx.Text != null ? _tx.Text.ToString() : ""; }

            ASPxComboBox _cb = (ASPxComboBox)this.fmvAddressBook.FindControl("dxcboCountry");
            if (_cb != null) { _n.CountryID = _cb.Value != null ? wwi_func.vint(_cb.Value.ToString()) : _intnull; }

            _tx = (ASPxTextBox)this.fmvAddressBook.FindControl("dxtxtPostCodeInsert");
            if (_tx != null) { _n.PostCode = _tx.Text != null ? _tx.Text.ToString() : ""; }

            _tx = (ASPxTextBox)this.fmvAddressBook.FindControl("dxtxtTelNoInsert");
            if (_tx != null) { _n.TelNo = _tx.Text != null ? _tx.Text.ToString() : ""; }

            _tx = (ASPxTextBox)this.fmvAddressBook.FindControl("dxtxtFaxInsert");
            if (_tx != null) { _n.FaxNo = _tx.Text != null ? _tx.Text.ToString() : ""; }

            _tx = (ASPxTextBox)this.fmvAddressBook.FindControl("dxtxtEmailInsert");
            if (_tx != null) { _n.MainEmail = _tx.Text != null ? _tx.Text.ToString() : ""; }

            _cb = (ASPxComboBox)this.fmvAddressBook.FindControl("dxcboCompanyType");
            if (_cb != null) { _n.TypeID = _cb.Value != null ? wwi_func.vint(_cb.Value.ToString()) : _intnull; }

            ASPxMemo _m = (ASPxMemo)this.fmvAddressBook.FindControl("dxmemoDeliveryInsert");
            if (_m != null) { _n.SpecialDeliveryInstructions = _m.Text != null ? _m.Text.ToString() : ""; }

            _tx = (ASPxTextBox)this.fmvAddressBook.FindControl("dxtxtPalletSpecInsert");
            if (_tx != null) { _n.PalletDims = _tx.Text != null ? _tx.Text.ToString() : ""; }

            _tx = (ASPxTextBox)this.fmvAddressBook.FindControl("dxtxtMaxWeightInsert"); //check for nullable int
            if (_tx != null)
            {
                int? _v = 0;
                if (!string.IsNullOrEmpty(_tx.Text.ToString())) { _v = wwi_func.vint(_tx.Text.ToString()); }
                _n.MaxPalletWeight = _v.Value;
            }

            _tx = (ASPxTextBox)this.fmvAddressBook.FindControl("dxtxtMaxHeightInsert"); //check for nullable int
            if (_tx != null)
            {
                int? _v = 0;
                if (!string.IsNullOrEmpty(_tx.Text.ToString())) { _v = wwi_func.vint(_tx.Text.ToString()); }
                _n.MaxPalletHeight  = _v.Value;
            }

            ASPxCheckBox _ck = (ASPxCheckBox)this.fmvAddressBook.FindControl("dxckExporterInsert");
            if (_ck != null) { _n.Exporter = _ck.Checked; }

            _ck = (ASPxCheckBox)this.fmvAddressBook.FindControl("dxckCustomerInsert");
            if (_ck != null) { _n.Customer = _ck.Checked; }

            _ck = (ASPxCheckBox)this.fmvAddressBook.FindControl("dxckConsigneeInsert");
            if (_ck != null) { _n.Consignee = _ck.Checked; }

            _ck = (ASPxCheckBox)this.fmvAddressBook.FindControl("dxckInsuranceInsert");
            if (_ck != null) { _n.Insurance = _ck.Checked; }

            _ck = (ASPxCheckBox)this.fmvAddressBook.FindControl("dxckSalesTargetInsert");
            if (_ck != null) { _n.SalesModule = _ck.Checked; }

            _n.Save();
            //return new company id
            //get new id
            _newid = (int)_n.GetPrimaryKeyValue();
        }
        catch(Exception ex)
        {
            string _ex = ex.Message.ToString();
            this.dxlblErr.Text = _ex;
            this.dxpnlErr.ClientVisible = true;
        }
        return _newid;
    }
Exemplo n.º 5
0
    //end formview inserting
    /// <summary>
    /// by binding in code behind we can avoid objectdatasource not updating nullable values correctly
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void update_company()
    {
        int _pid     = wwi_func.vint(wwi_security.DecryptString(get_token("pid").ToString(), "publiship"));
        int?_intnull = null;

        if (_pid > 0)
        {
            try
            {
                //ASPxLabel _lb = (ASPxLabel)_f.FindControl("dxlblCompanyID");
                //if (_lb != null) { _id = _lb.Text.ToString(); }

                NameAndAddressBook _n = new NameAndAddressBook(_pid);

                ASPxTextBox _tx = (ASPxTextBox)this.fmvAddressBook.FindControl("dxtxtName");
                if (_tx != null)
                {
                    _n.CompanyName = _tx.Text != null?_tx.Text.ToString() : "";
                }

                _tx = (ASPxTextBox)this.fmvAddressBook.FindControl("dxtxtAddress1");
                if (_tx != null)
                {
                    _n.Address1 = _tx.Text != null?_tx.Text.ToString() : "";
                }

                _tx = (ASPxTextBox)this.fmvAddressBook.FindControl("dxtxtAddress2");
                if (_tx != null)
                {
                    _n.Address2 = _tx.Text != null?_tx.Text.ToString() : "";
                }

                _tx = (ASPxTextBox)this.fmvAddressBook.FindControl("dxtxtAddress3");
                if (_tx != null)
                {
                    _n.Address3 = _tx.Text != null?_tx.Text.ToString() : "";
                }

                ASPxComboBox _cb = (ASPxComboBox)this.fmvAddressBook.FindControl("dxcboCountry");
                if (_cb != null)
                {
                    _n.CountryID = wwi_func.vint(_cb.Value.ToString());
                }

                _tx = (ASPxTextBox)this.fmvAddressBook.FindControl("dxtxtPostCode");
                if (_tx != null)
                {
                    _n.PostCode = _tx.Text != null?_tx.Text.ToString() : "";
                }

                _tx = (ASPxTextBox)this.fmvAddressBook.FindControl("dxtxtTelNo");
                if (_tx != null)
                {
                    _n.TelNo = _tx.Text != null?_tx.Text.ToString() : "";
                }

                _tx = (ASPxTextBox)this.fmvAddressBook.FindControl("dxtxtFax");
                if (_tx != null)
                {
                    _n.FaxNo = _tx.Text != null?_tx.Text.ToString() : "";
                }

                _tx = (ASPxTextBox)this.fmvAddressBook.FindControl("dxtxtEmail");
                if (_tx != null)
                {
                    _n.MainEmail = _tx.Text != null?_tx.Text.ToString() : "";
                }

                _cb = (ASPxComboBox)this.fmvAddressBook.FindControl("dxcboCompanyType");
                if (_cb != null)
                {
                    _n.TypeID = _cb.Value != null?wwi_func.vint(_cb.Value.ToString()) : _intnull;
                }

                ASPxMemo _m = (ASPxMemo)this.fmvAddressBook.FindControl("dxmemoDelivery");
                if (_m != null)
                {
                    _n.SpecialDeliveryInstructions = _m.Text != null?_m.Text.ToString() : "";
                }

                _tx = (ASPxTextBox)this.fmvAddressBook.FindControl("dxtxtPalletSpec");
                if (_tx != null)
                {
                    _n.PalletDims = _tx.Text != null?_tx.Text.ToString() : "";
                }

                _tx = (ASPxTextBox)this.fmvAddressBook.FindControl("dxtxtMaxWeight"); //check for nullable int
                if (_tx != null)
                {
                    int?_v = 0;
                    if (!string.IsNullOrEmpty(_tx.Text.ToString()))
                    {
                        _v = wwi_func.vint(_tx.Text.ToString());
                    }
                    _n.MaxPalletWeight = _v;
                }

                _tx = (ASPxTextBox)this.fmvAddressBook.FindControl("dxtxtMaxHeight"); //check for nullable int
                if (_tx != null)
                {
                    int?_v = 0;
                    if (!string.IsNullOrEmpty(_tx.Text.ToString()))
                    {
                        _v = wwi_func.vint(_tx.Text.ToString());
                    }
                    _n.MaxPalletHeight = _v;
                }

                ASPxCheckBox _ck = (ASPxCheckBox)this.fmvAddressBook.FindControl("dxckExporter");
                if (_ck != null)
                {
                    _n.Exporter = _ck.Checked;
                }

                _ck = (ASPxCheckBox)this.fmvAddressBook.FindControl("dxckCustomer");
                if (_ck != null)
                {
                    _n.Customer = _ck.Checked;
                }

                _ck = (ASPxCheckBox)this.fmvAddressBook.FindControl("dxckConsignee");
                if (_ck != null)
                {
                    _n.Consignee = _ck.Checked;
                }

                _ck = (ASPxCheckBox)this.fmvAddressBook.FindControl("dxckInsurance");
                if (_ck != null)
                {
                    _n.Insurance = _ck.Checked;
                }

                _ck = (ASPxCheckBox)this.fmvAddressBook.FindControl("dxckSalesTarget");
                if (_ck != null)
                {
                    _n.SalesModule = _ck.Checked;
                }

                _n.Save();

                //end formview updating
            }
            catch (Exception ex)
            {
                string _ex = ex.Message.ToString();
                this.dxlblErr.Text          = _ex;
                this.dxpnlErr.ClientVisible = true;
            }
        }
        else
        {
            string _ex = "Can't update record Comapny ID = 0";
            this.dxlblErr.Text          = _ex;
            this.dxpnlErr.ClientVisible = true;
        }
    }
Exemplo n.º 6
0
    }//end menu names loop

    #endregion

    #region company crud operations
    protected int insert_company()
    {
        int _user    = Page.Session["user"] != null ? (int)((UserClass)Page.Session["user"]).UserId : 0;
        int?_intnull = null;
        int _newid   = 0;

        try
        {
            NameAndAddressBook _n = new NameAndAddressBook();
            _n.DateRecordAdded = DateTime.Now;
            _n.RecordAddedBY   = _user;

            ASPxTextBox _tx = (ASPxTextBox)this.fmvAddressBook.FindControl("dxtxtNameInsert");
            if (_tx != null)
            {
                _n.CompanyName = _tx.Text != null?_tx.Text.ToString() : "";
            }

            _tx = (ASPxTextBox)this.fmvAddressBook.FindControl("dxtxtAddress1Insert");
            if (_tx != null)
            {
                _n.Address1 = _tx.Text != null?_tx.Text.ToString() : "";
            }

            _tx = (ASPxTextBox)this.fmvAddressBook.FindControl("dxtxtAddress2Insert");
            if (_tx != null)
            {
                _n.Address2 = _tx.Text != null?_tx.Text.ToString() : "";
            }

            _tx = (ASPxTextBox)this.fmvAddressBook.FindControl("dxtxtAddress3Insert");
            if (_tx != null)
            {
                _n.Address3 = _tx.Text != null?_tx.Text.ToString() : "";
            }

            ASPxComboBox _cb = (ASPxComboBox)this.fmvAddressBook.FindControl("dxcboCountry");
            if (_cb != null)
            {
                _n.CountryID = _cb.Value != null?wwi_func.vint(_cb.Value.ToString()) : _intnull;
            }

            _tx = (ASPxTextBox)this.fmvAddressBook.FindControl("dxtxtPostCodeInsert");
            if (_tx != null)
            {
                _n.PostCode = _tx.Text != null?_tx.Text.ToString() : "";
            }

            _tx = (ASPxTextBox)this.fmvAddressBook.FindControl("dxtxtTelNoInsert");
            if (_tx != null)
            {
                _n.TelNo = _tx.Text != null?_tx.Text.ToString() : "";
            }

            _tx = (ASPxTextBox)this.fmvAddressBook.FindControl("dxtxtFaxInsert");
            if (_tx != null)
            {
                _n.FaxNo = _tx.Text != null?_tx.Text.ToString() : "";
            }

            _tx = (ASPxTextBox)this.fmvAddressBook.FindControl("dxtxtEmailInsert");
            if (_tx != null)
            {
                _n.MainEmail = _tx.Text != null?_tx.Text.ToString() : "";
            }

            _cb = (ASPxComboBox)this.fmvAddressBook.FindControl("dxcboCompanyType");
            if (_cb != null)
            {
                _n.TypeID = _cb.Value != null?wwi_func.vint(_cb.Value.ToString()) : _intnull;
            }

            ASPxMemo _m = (ASPxMemo)this.fmvAddressBook.FindControl("dxmemoDeliveryInsert");
            if (_m != null)
            {
                _n.SpecialDeliveryInstructions = _m.Text != null?_m.Text.ToString() : "";
            }

            _tx = (ASPxTextBox)this.fmvAddressBook.FindControl("dxtxtPalletSpecInsert");
            if (_tx != null)
            {
                _n.PalletDims = _tx.Text != null?_tx.Text.ToString() : "";
            }

            _tx = (ASPxTextBox)this.fmvAddressBook.FindControl("dxtxtMaxWeightInsert"); //check for nullable int
            if (_tx != null)
            {
                int?_v = 0;
                if (!string.IsNullOrEmpty(_tx.Text.ToString()))
                {
                    _v = wwi_func.vint(_tx.Text.ToString());
                }
                _n.MaxPalletWeight = _v.Value;
            }

            _tx = (ASPxTextBox)this.fmvAddressBook.FindControl("dxtxtMaxHeightInsert"); //check for nullable int
            if (_tx != null)
            {
                int?_v = 0;
                if (!string.IsNullOrEmpty(_tx.Text.ToString()))
                {
                    _v = wwi_func.vint(_tx.Text.ToString());
                }
                _n.MaxPalletHeight = _v.Value;
            }

            ASPxCheckBox _ck = (ASPxCheckBox)this.fmvAddressBook.FindControl("dxckExporterInsert");
            if (_ck != null)
            {
                _n.Exporter = _ck.Checked;
            }

            _ck = (ASPxCheckBox)this.fmvAddressBook.FindControl("dxckCustomerInsert");
            if (_ck != null)
            {
                _n.Customer = _ck.Checked;
            }

            _ck = (ASPxCheckBox)this.fmvAddressBook.FindControl("dxckConsigneeInsert");
            if (_ck != null)
            {
                _n.Consignee = _ck.Checked;
            }

            _ck = (ASPxCheckBox)this.fmvAddressBook.FindControl("dxckInsuranceInsert");
            if (_ck != null)
            {
                _n.Insurance = _ck.Checked;
            }

            _ck = (ASPxCheckBox)this.fmvAddressBook.FindControl("dxckSalesTargetInsert");
            if (_ck != null)
            {
                _n.SalesModule = _ck.Checked;
            }

            _n.Save();
            //return new company id
            //get new id
            _newid = (int)_n.GetPrimaryKeyValue();
        }
        catch (Exception ex)
        {
            string _ex = ex.Message.ToString();
            this.dxlblErr.Text          = _ex;
            this.dxpnlErr.ClientVisible = true;
        }
        return(_newid);
    }
Exemplo n.º 7
0
    //end formview inserting
    /// <summary>
    /// by binding in code behind we can avoid objectdatasource not updating nullable values correctly
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void fmvAddressBook_ItemUpdating(object sender, FormViewUpdateEventArgs e)
    {
        int _id      = wwi_func.vint(get_token("pid"));
        int?_intnull = null;

        if (_id > 0)
        {
            FormView _f = (FormView)this.FindControl("fmvAddressBook");
            if (_f != null)
            {
                //ASPxLabel _lb = (ASPxLabel)_f.FindControl("dxlblCompanyID");
                //if (_lb != null) { _id = _lb.Text.ToString(); }

                NameAndAddressBook _n = new NameAndAddressBook(_id);

                ASPxTextBox _tx = (ASPxTextBox)_f.FindControl("dxtxtName");
                if (_tx != null)
                {
                    _n.CompanyName = _tx.Text != null?_tx.Text.ToString() : "";
                }

                _tx = (ASPxTextBox)_f.FindControl("dxtxtAddress1");
                if (_tx != null)
                {
                    _n.Address1 = _tx.Text != null?_tx.Text.ToString() : "";
                }

                _tx = (ASPxTextBox)_f.FindControl("dxtxtAddress2");
                if (_tx != null)
                {
                    _n.Address2 = _tx.Text != null?_tx.Text.ToString() : "";
                }

                _tx = (ASPxTextBox)_f.FindControl("dxtxtAddress3");
                if (_tx != null)
                {
                    _n.Address3 = _tx.Text != null?_tx.Text.ToString() : "";
                }

                ASPxComboBox _cb = (ASPxComboBox)_f.FindControl("dxcboCountry");
                if (_cb != null)
                {
                    _n.CountryID = wwi_func.vint(_cb.Value.ToString());
                }

                _tx = (ASPxTextBox)_f.FindControl("dxtxtPostCode");
                if (_tx != null)
                {
                    _n.PostCode = _tx.Text != null?_tx.Text.ToString() : "";
                }

                _tx = (ASPxTextBox)_f.FindControl("dxtxtTelNo");
                if (_tx != null)
                {
                    _n.TelNo = _tx.Text != null?_tx.Text.ToString() : "";
                }

                _tx = (ASPxTextBox)_f.FindControl("dxtxtFax");
                if (_tx != null)
                {
                    _n.FaxNo = _tx.Text != null?_tx.Text.ToString() : "";
                }

                _tx = (ASPxTextBox)_f.FindControl("dxtxtEmail");
                if (_tx != null)
                {
                    _n.MainEmail = _tx.Text != null?_tx.Text.ToString() : "";
                }

                _cb = (ASPxComboBox)_f.FindControl("dxcboCompanyType");
                if (_cb != null)
                {
                    _n.TypeID = _cb.Value != null?wwi_func.vint(_cb.Value.ToString()) : _intnull;
                }

                ASPxMemo _m = (ASPxMemo)_f.FindControl("dxmemoDelivery");
                if (_m != null)
                {
                    _n.SpecialDeliveryInstructions = _m.Text != null?_m.Text.ToString() : "";
                }

                _tx = (ASPxTextBox)_f.FindControl("dxtxtPalletSpec");
                if (_tx != null)
                {
                    _n.PalletDims = _tx.Text != null?_tx.Text.ToString() : "";
                }

                _tx = (ASPxTextBox)_f.FindControl("dxtxtMaxWeight"); //check for nullable int
                if (_tx != null)
                {
                    int?_v = 0;
                    if (!string.IsNullOrEmpty(_tx.Text.ToString()))
                    {
                        _v = wwi_func.vint(_tx.Text.ToString());
                    }
                    _n.MaxPalletWeight = _v;
                }

                _tx = (ASPxTextBox)_f.FindControl("dxtxtMaxHeight"); //check for nullable int
                if (_tx != null)
                {
                    int?_v = 0;
                    if (!string.IsNullOrEmpty(_tx.Text.ToString()))
                    {
                        _v = wwi_func.vint(_tx.Text.ToString());
                    }
                    _n.MaxPalletHeight = _v;
                }

                ASPxCheckBox _ck = (ASPxCheckBox)_f.FindControl("dxckExporter");
                if (_ck != null)
                {
                    _n.Exporter = _ck.Checked;
                }

                _ck = (ASPxCheckBox)_f.FindControl("dxckCustomer");
                if (_ck != null)
                {
                    _n.Customer = _ck.Checked;
                }

                _ck = (ASPxCheckBox)_f.FindControl("dxckConsignee");
                if (_ck != null)
                {
                    _n.Consignee = _ck.Checked;
                }

                _ck = (ASPxCheckBox)_f.FindControl("dxckInsurance");
                if (_ck != null)
                {
                    _n.Insurance = _ck.Checked;
                }

                _ck = (ASPxCheckBox)_f.FindControl("dxckSalesTarget");
                if (_ck != null)
                {
                    _n.SalesModule = _ck.Checked;
                }

                _n.Save();
            }
            //end formview updating
        }
    }
Exemplo n.º 8
0
    }//end menu names loop

    #endregion

    #region company crud operations
    protected void fmvAddressBook_ItemInserting(object sender, FormViewInsertEventArgs e)
    {
        int _user    = Page.Session["user"] != null ? (int)((UserClass)Page.Session["user"]).UserId : 0;
        int?_intnull = null;
        //this.objdsAddressBook.InsertParameters["DateRecordAdded"].DefaultValue = DateTime.Now.ToShortDateString();
        //this.objdsAddressBook.InsertParameters["RecordAddedBY"].DefaultValue = _username;
        FormView _f = (FormView)this.FindControl("fmvAddressBook");

        if (_f != null)
        {
            NameAndAddressBook _n = new NameAndAddressBook();
            _n.DateRecordAdded = DateTime.Now;
            _n.RecordAddedBY   = _user;

            ASPxTextBox _tx = (ASPxTextBox)_f.FindControl("dxtxtname");
            if (_tx != null)
            {
                _n.CompanyName = _tx.Text != null?_tx.Text.ToString() : "";
            }

            _tx = (ASPxTextBox)_f.FindControl("dxtxtAddress1");
            if (_tx != null)
            {
                _n.Address1 = _tx.Text != null?_tx.Text.ToString() : "";
            }

            _tx = (ASPxTextBox)_f.FindControl("dxtxtAddress2");
            if (_tx != null)
            {
                _n.Address2 = _tx.Text != null?_tx.Text.ToString() : "";
            }

            _tx = (ASPxTextBox)_f.FindControl("dxtxtAddress3");
            if (_tx != null)
            {
                _n.Address3 = _tx.Text != null?_tx.Text.ToString() : "";
            }

            ASPxComboBox _cb = (ASPxComboBox)_f.FindControl("dxcboCountry");
            if (_cb != null)
            {
                _n.CountryID = _cb.Value != null?wwi_func.vint(_cb.Value.ToString()) : _intnull;
            }

            _tx = (ASPxTextBox)_f.FindControl("dxtxtPostCode");
            if (_tx != null)
            {
                _n.PostCode = _tx.Text != null?_tx.Text.ToString() : "";
            }

            _tx = (ASPxTextBox)_f.FindControl("dxtxtTelNo");
            if (_tx != null)
            {
                _n.TelNo = _tx.Text != null?_tx.Text.ToString() : "";
            }

            _tx = (ASPxTextBox)_f.FindControl("dxtxtFax");
            if (_tx != null)
            {
                _n.FaxNo = _tx.Text != null?_tx.Text.ToString() : "";
            }

            _tx = (ASPxTextBox)_f.FindControl("dxtxtEmail");
            if (_tx != null)
            {
                _n.MainEmail = _tx.Text != null?_tx.Text.ToString() : "";
            }

            _cb = (ASPxComboBox)_f.FindControl("dxcboCompanyType");
            if (_cb != null)
            {
                _n.TypeID = _cb.Value != null?wwi_func.vint(_cb.Value.ToString()) : _intnull;
            }

            ASPxMemo _m = (ASPxMemo)_f.FindControl("dxmemoDelivery");
            if (_m != null)
            {
                _n.SpecialDeliveryInstructions = _m.Text != null?_m.Text.ToString() : "";
            }

            _tx = (ASPxTextBox)_f.FindControl("dxtxtPalletSpec");
            if (_tx != null)
            {
                _n.PalletDims = _tx.Text != null?_tx.Text.ToString() : "";
            }

            _tx = (ASPxTextBox)_f.FindControl("dxtxtMaxWeight"); //check for nullable int
            if (_tx != null)
            {
                int?_v = 0;
                if (!string.IsNullOrEmpty(_tx.Text.ToString()))
                {
                    _v = wwi_func.vint(_tx.Text.ToString());
                }
                _n.MaxPalletWeight = _v.Value;
            }

            _tx = (ASPxTextBox)_f.FindControl("dxtxtMaxHeight"); //check for nullable int
            if (_tx != null)
            {
                int?_v = 0;
                if (!string.IsNullOrEmpty(_tx.Text.ToString()))
                {
                    _v = wwi_func.vint(_tx.Text.ToString());
                }
                _n.MaxPalletHeight = _v.Value;
            }

            ASPxCheckBox _ck = (ASPxCheckBox)_f.FindControl("dxckExporter");
            if (_ck != null)
            {
                _n.Exporter = _ck.Checked;
            }

            _ck = (ASPxCheckBox)_f.FindControl("dxckCustomer");
            if (_ck != null)
            {
                _n.Customer = _ck.Checked;
            }

            _ck = (ASPxCheckBox)_f.FindControl("dxckConsignee");
            if (_ck != null)
            {
                _n.Consignee = _ck.Checked;
            }

            _ck = (ASPxCheckBox)_f.FindControl("dxckInsurance");
            if (_ck != null)
            {
                _n.Insurance = _ck.Checked;
            }

            _ck = (ASPxCheckBox)_f.FindControl("dxckSalesTarget");
            if (_ck != null)
            {
                _n.SalesModule = _ck.Checked;
            }

            _n.Save();
            //return new company id
            int _newid = (Int32)_n.GetPrimaryKeyValue();
            //add to hidden field as we won't be able to retrive this from page request
            if (this.dxhfOrder.Contains("pid"))
            {
                this.dxhfOrder.Remove("pid");
            }
            this.dxhfOrder.Add("pid", _newid);
            ///update id label
            ASPxLabel _lb = (ASPxLabel)_f.FindControl("dxlblCompanyID");
            if (_lb != null)
            {
                _lb.Text = _newid.ToString();
            }
        }
    }
    //end formview inserting
    /// <summary>
    /// by binding in code behind we can avoid objectdatasource not updating nullable values correctly
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void fmvAddressBook_ItemUpdating(object sender, FormViewUpdateEventArgs e)
    {
        int _id = wwi_func.vint(get_token("pid"));
        int? _intnull = null;

        if (_id > 0)
        {
            FormView _f = (FormView)this.FindControl("fmvAddressBook");
            if (_f != null)
            {
                //ASPxLabel _lb = (ASPxLabel)_f.FindControl("dxlblCompanyID");
                //if (_lb != null) { _id = _lb.Text.ToString(); }

                NameAndAddressBook _n = new NameAndAddressBook(_id);

                ASPxTextBox _tx = (ASPxTextBox)_f.FindControl("dxtxtName");
                if (_tx != null) { _n.CompanyName = _tx.Text != null ? _tx.Text.ToString() : ""; }

                _tx = (ASPxTextBox)_f.FindControl("dxtxtAddress1");
                if (_tx != null) { _n.Address1 = _tx.Text != null ? _tx.Text.ToString() : ""; }

                _tx = (ASPxTextBox)_f.FindControl("dxtxtAddress2");
                if (_tx != null) { _n.Address2 = _tx.Text != null ? _tx.Text.ToString() : ""; }

                _tx = (ASPxTextBox)_f.FindControl("dxtxtAddress3");
                if (_tx != null) { _n.Address3 = _tx.Text != null ? _tx.Text.ToString() : ""; }

                ASPxComboBox _cb = (ASPxComboBox)_f.FindControl("dxcboCountry");
                if (_cb != null) { _n.CountryID = wwi_func.vint(_cb.Value.ToString()); }

                _tx = (ASPxTextBox)_f.FindControl("dxtxtPostCode");
                if (_tx != null) { _n.PostCode = _tx.Text != null ? _tx.Text.ToString() : ""; }

                _tx = (ASPxTextBox)_f.FindControl("dxtxtTelNo");
                if (_tx != null) { _n.TelNo = _tx.Text != null ? _tx.Text.ToString() : ""; }

                _tx = (ASPxTextBox)_f.FindControl("dxtxtFax");
                if (_tx != null) { _n.FaxNo = _tx.Text != null ? _tx.Text.ToString() : ""; }

                _tx = (ASPxTextBox)_f.FindControl("dxtxtEmail");
                if (_tx != null) { _n.MainEmail = _tx.Text != null ? _tx.Text.ToString() : ""; }

                _cb = (ASPxComboBox)_f.FindControl("dxcboCompanyType");
                if (_cb != null) { _n.TypeID = _cb.Value != null ? wwi_func.vint(_cb.Value.ToString()) : _intnull; }

                ASPxMemo _m = (ASPxMemo)_f.FindControl("dxmemoDelivery");
                if (_m != null) { _n.SpecialDeliveryInstructions = _m.Text!= null? _m.Text.ToString(): ""; }

                _tx = (ASPxTextBox)_f.FindControl("dxtxtPalletSpec");
                if (_tx != null) { _n.PalletDims = _tx.Text != null ? _tx.Text.ToString() : ""; }

                _tx = (ASPxTextBox)_f.FindControl("dxtxtMaxWeight"); //check for nullable int
                if (_tx != null)
                {
                    int? _v = 0;
                    if (!string.IsNullOrEmpty(_tx.Text.ToString())) { _v = wwi_func.vint(_tx.Text.ToString()); }
                    _n.MaxPalletWeight = _v;
                }

                _tx = (ASPxTextBox)_f.FindControl("dxtxtMaxHeight"); //check for nullable int
                if (_tx != null)
                {
                    int? _v = 0;
                    if (!string.IsNullOrEmpty(_tx.Text.ToString())) { _v = wwi_func.vint(_tx.Text.ToString()); }
                    _n.MaxPalletHeight = _v;
                }

                ASPxCheckBox _ck = (ASPxCheckBox)_f.FindControl("dxckExporter");
                if (_ck != null) { _n.Exporter = _ck.Checked; }

                _ck = (ASPxCheckBox)_f.FindControl("dxckCustomer");
                if (_ck != null) { _n.Customer = _ck.Checked; }

                _ck = (ASPxCheckBox)_f.FindControl("dxckConsignee");
                if (_ck != null) { _n.Consignee = _ck.Checked; }

                _ck = (ASPxCheckBox)_f.FindControl("dxckInsurance");
                if (_ck != null) { _n.Insurance = _ck.Checked; }

                _ck = (ASPxCheckBox)_f.FindControl("dxckSalesTarget");
                if (_ck != null) { _n.SalesModule = _ck.Checked; }

                _n.Save();
            }
            //end formview updating
        }
    }
    }//end menu names loop

    #endregion

    #region company crud operations
    protected void fmvAddressBook_ItemInserting(object sender, FormViewInsertEventArgs e)
    {
        int _user = Page.Session["user"] != null ? (int)((UserClass)Page.Session["user"]).UserId : 0;
        int? _intnull = null;
        //this.objdsAddressBook.InsertParameters["DateRecordAdded"].DefaultValue = DateTime.Now.ToShortDateString();
        //this.objdsAddressBook.InsertParameters["RecordAddedBY"].DefaultValue = _username;
        FormView _f = (FormView)this.FindControl("fmvAddressBook");
        if (_f != null)
        {
            NameAndAddressBook _n = new NameAndAddressBook();
            _n.DateRecordAdded = DateTime.Now;
            _n.RecordAddedBY = _user;

            ASPxTextBox _tx = (ASPxTextBox)_f.FindControl("dxtxtname");
            if (_tx != null) { _n.CompanyName = _tx.Text != null? _tx.Text.ToString(): ""; }

            _tx = (ASPxTextBox)_f.FindControl("dxtxtAddress1");
            if (_tx != null) { _n.Address1 = _tx.Text != null ? _tx.Text.ToString() : ""; }

            _tx = (ASPxTextBox)_f.FindControl("dxtxtAddress2");
            if (_tx != null) { _n.Address2 = _tx.Text != null ? _tx.Text.ToString() : ""; }

            _tx = (ASPxTextBox)_f.FindControl("dxtxtAddress3");
            if (_tx != null) { _n.Address3 = _tx.Text != null ? _tx.Text.ToString() : ""; }

            ASPxComboBox _cb = (ASPxComboBox)_f.FindControl("dxcboCountry");
            if (_cb != null) { _n.CountryID = _cb.Value != null? wwi_func.vint(_cb.Value.ToString()): _intnull; }

            _tx = (ASPxTextBox)_f.FindControl("dxtxtPostCode");
            if (_tx != null) { _n.PostCode = _tx.Text != null ? _tx.Text.ToString() : ""; }

            _tx = (ASPxTextBox)_f.FindControl("dxtxtTelNo");
            if (_tx != null) { _n.TelNo = _tx.Text != null ? _tx.Text.ToString() : ""; }

            _tx = (ASPxTextBox)_f.FindControl("dxtxtFax");
            if (_tx != null) { _n.FaxNo = _tx.Text != null ? _tx.Text.ToString() : ""; }

            _tx = (ASPxTextBox)_f.FindControl("dxtxtEmail");
            if (_tx != null) { _n.MainEmail = _tx.Text != null ? _tx.Text.ToString() : ""; }

            _cb = (ASPxComboBox)_f.FindControl("dxcboCompanyType");
            if (_cb != null) { _n.TypeID = _cb.Value != null ? wwi_func.vint(_cb.Value.ToString()) : _intnull; }

            ASPxMemo _m = (ASPxMemo)_f.FindControl("dxmemoDelivery");
            if (_m != null) { _n.SpecialDeliveryInstructions = _m.Text != null ? _m.Text.ToString() : ""; }

            _tx = (ASPxTextBox)_f.FindControl("dxtxtPalletSpec");
            if (_tx != null) { _n.PalletDims = _tx.Text != null ? _tx.Text.ToString() : ""; }

            _tx = (ASPxTextBox)_f.FindControl("dxtxtMaxWeight"); //check for nullable int
            if (_tx != null)
            {
                int? _v = 0;
                if (!string.IsNullOrEmpty(_tx.Text.ToString())) { _v = wwi_func.vint(_tx.Text.ToString()); }
                _n.MaxPalletWeight = _v.Value;
            }

            _tx = (ASPxTextBox)_f.FindControl("dxtxtMaxHeight"); //check for nullable int
            if (_tx != null)
            {
                int? _v = 0;
                if (!string.IsNullOrEmpty(_tx.Text.ToString())) { _v = wwi_func.vint(_tx.Text.ToString()); }
                _n.MaxPalletHeight = _v.Value;
            }

            ASPxCheckBox _ck = (ASPxCheckBox)_f.FindControl("dxckExporter");
            if (_ck != null) { _n.Exporter = _ck.Checked; }

            _ck = (ASPxCheckBox)_f.FindControl("dxckCustomer");
            if (_ck != null) { _n.Customer = _ck.Checked; }

            _ck = (ASPxCheckBox)_f.FindControl("dxckConsignee");
            if (_ck != null) { _n.Consignee = _ck.Checked; }

            _ck = (ASPxCheckBox)_f.FindControl("dxckInsurance");
            if (_ck != null) { _n.Insurance = _ck.Checked; }

            _ck = (ASPxCheckBox)_f.FindControl("dxckSalesTarget");
            if (_ck != null) { _n.SalesModule = _ck.Checked; }

            _n.Save();
            //return new company id
            int _newid = (Int32)_n.GetPrimaryKeyValue();
            //add to hidden field as we won't be able to retrive this from page request
            if (this.dxhfOrder.Contains("pid")) { this.dxhfOrder.Remove("pid"); }
            this.dxhfOrder.Add("pid", _newid);
            ///update id label
            ASPxLabel _lb = (ASPxLabel)_f.FindControl("dxlblCompanyID");
            if (_lb != null) { _lb.Text = _newid.ToString(); }
        }
    }