コード例 #1
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();
        }
    }
    protected void btnUpdate_Click(object sender, EventArgs e)
    {
        int FlagStatus;
        int siteid = Convert.ToInt16(Request.QueryString[0]);
        objSite = objSite.Get_By_id(siteid);
        int varFlagSiteExist;
        varFlagSiteExist = objSite.Get_By_SiteName(txtSitename.Text.ToString().Trim(), Convert.ToInt16(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.ToInt16(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.ToInt16(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();
            objAreamanager.AreaManagerName = txtAreaManagerName.Text.ToString().Trim();
            objAreamanager.Email = txtEmail.Text.ToString().Trim();
            Custid = Convert.ToInt16(ViewState["CustId"].ToString());
            objCustToSite.Delete(Custid, siteid);
            objCustToSite.Custid = Convert.ToInt16(drpCustomer.SelectedValue);
            objCustToSite.Siteid = siteid;
            objCustToSite.Insert();

            if (dropEnable.SelectedValue == "1")
            {

            }
            else
            {
                objSite.Enable = false;
            }
            //  Call Function objSite.Update() to update the Site values in Database
            FlagStatus = objSite.Update();

            FlagStatus = objAreamanager.Update();
            if (FlagStatus == 1)
            {
                objSite.Enable = true;
                //////////////////Now add data for Area manager//////////////////////////////////
                objAreamanager.Siteid = siteid;//
                objAreamanager.AreaManagerName = txtAreaManagerName.Text;
                objAreamanager.Email = txtEmail.Text;
                objAreamanager.Update();

                ////////////////////////////////////////////////////////////////////////////////

                // 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();
        }
    }