Esempio n. 1
0
    protected void btnregionadd_Click(object sender, EventArgs e)
    {
        // Declare Local variable varStatus and varFlagSiteExist
        int varStatus;
        int varFlagSiteExist;

        // To Check Whether Site Exist in Particular Region ,and assign status to field varFlagSiteExist
        varFlagSiteExist = objSite.Get_By_SiteName(txtSitename.Text.ToString().Trim(), Convert.ToInt32(drpRegion.SelectedValue));
        // If field varFlagSiteExist is zero than Site Not Exist
        if (varFlagSiteExist == 0)
        {
            // Assign Controls Values to Object Fields
            objSite.Sitename          = txtSitename.Text.ToString().Trim();
            objSite.Description       = txtSitedesc.Text.ToString().Trim();
            objSite.Regionid          = Convert.ToInt32(drpRegion.SelectedValue);
            objSite.Address           = txtAddress.Text.ToString().Trim();
            objSite.City              = txtCity.Text.ToString().Trim();
            objSite.Postalcode        = txtPostalCode.Text.ToString().Trim();
            objSite.State             = txtState.Text.ToString().Trim();
            objSite.Countryid         = Convert.ToInt32(drpCountry.SelectedValue);
            objSite.Createdatetime    = DateTime.Now.ToString();
            objSite.Phoneno           = txtPhoneNo.Text.ToString().Trim();
            objSite.Faxno             = txtFaxNo.Text.ToString().Trim();
            objSite.Emailid           = txtEmailId.Text.ToString().Trim();
            objSite.Website           = txtWebSiteUrl.Text.ToString().Trim();
            objSite.Contactpersonname = txtPersonName.Text.ToString().Trim();
            objSite.Mobileno          = txtMobileno.Text.ToString().Trim();
            objSite.Enable            = true;
            // Check Status whether data inserted in Database is successfully or not,and assign status  to field  varStatus
            varStatus = objSite.Insert();
            // If varStatus is 1 then data save successfully otherwies Error occurred
            if (varStatus == 1)
            {
                int siteid;
                siteid = objSite.Get_TopSiteId();
                int custid = Convert.ToInt32(drpCustomer.SelectedValue);
                objCustToSite.Custid = custid;
                objCustToSite.Siteid = siteid;
                objCustToSite.Insert();

                Response.Redirect("~/admin/ViewSite.aspx");
            }
            else
            {
                lblErrorMsg.Text = Resources.MessageResource.errOccured.ToString();
            }
            // Calling function Clear() to clear all fields in forms
            Clear();
        }
        else
        {
            // Show Message Site Already Exist
            lblErrorMsg.Text = Resources.MessageResource.errSiteExist.ToString();
        }
    }