}//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;
    }
Example #2
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();
            }
        }
    }
Example #3
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);
    }
    }//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(); }
        }
    }