Пример #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();
        }
    }
Пример #2
0
    protected void btnUpdate_Click(object sender, EventArgs e)
    {
        int FlagStatus;
        int siteid = Convert.ToInt32(Request.QueryString[0]);

        objSite = objSite.Get_By_id(siteid);
        int varFlagSiteExist;

        varFlagSiteExist = objSite.Get_By_SiteName(txtSitename.Text.ToString().Trim(), Convert.ToInt32(drpRegion.SelectedValue));

        if ((varFlagSiteExist == 0) || (objSite.Sitename == txtSitename.Text.ToString().Trim()))
        {
            int Custid;
            objSite.Siteid            = siteid;
            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();
            Custid = Convert.ToInt32(ViewState["CustId"].ToString());
            objCustToSite.Delete(Custid, siteid);
            objCustToSite.Custid = Convert.ToInt32(drpCustomer.SelectedValue);
            objCustToSite.Siteid = siteid;
            objCustToSite.Insert();


            if (dropEnable.SelectedValue == "1")
            {
                objSite.Enable = true;
            }
            else
            {
                objSite.Enable = false;
            }
            //  Call Function objSite.Update() to update the Site values in Database
            FlagStatus = objSite.Update();

            if (FlagStatus == 1)
            {
                // Redirect to page ViewSite.aspx page after successfully Updation
                Response.Redirect("~/admin/ViewSite.aspx");
            }
            else
            {
                // If Updation is not successfully,Display Error Message
                lblErrorMsg.Text = Resources.MessageResource.errOccured.ToString().Trim();
            }
        }
        else
        {
            // Show Message Site Already Exist
            lblErrorMsg.Text = Resources.MessageResource.errSiteExist.ToString();
        }
    }