Exemplo 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();
        }
    }
Exemplo n.º 2
0
    protected void UpdateSite()
    {
        int varFlagSiteExist;
        int Custid = 0;

        // 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));
        // Declare Local Variable siteid ,hold the Query String value passed from ViewSite.aspx page
        int siteid = Convert.ToInt32(Request.QueryString[0]);

        // Get the Instance of Site_mst Class and Assign to Object Variable objSite
        objSite = objSite.Get_By_id(siteid);
        // Check ,Instance Exist or Not
        if ((objSite.Siteid != 0) && (varFlagSiteExist == 0))
        {
            // Assign form fields values via object fields values
            txtSitename.Text         = objSite.Sitename.ToString().Trim();
            txtSitedesc.Text         = objSite.Description.ToString().Trim();
            drpRegion.SelectedValue  = Convert.ToString(objSite.Regionid);
            drpCountry.SelectedValue = Convert.ToString(objSite.Countryid);
            txtAddress.Text          = objSite.Address.ToString().Trim();
            txtCity.Text             = objSite.City.ToString().Trim();
            txtEmailId.Text          = objSite.Emailid.ToString().Trim();
            txtFaxNo.Text            = objSite.Faxno.ToString().Trim();
            txtMobileno.Text         = objSite.Mobileno.ToString().Trim();
            txtPersonName.Text       = objSite.Contactpersonname.ToString().Trim();
            txtPhoneNo.Text          = objSite.Phoneno.ToString().Trim();
            txtPostalCode.Text       = objSite.Postalcode.ToString().Trim();
            txtState.Text            = objSite.State.ToString().Trim();
            txtWebSiteUrl.Text       = objSite.Website.ToString().Trim();
            colCustToSite            = objCustToSite.Get_All_By_siteid(objSite.Siteid);

            foreach (CustomerToSiteMapping obj in colCustToSite)
            {
                Custid = obj.Custid;
            }
            ViewState["CustId"]       = Custid;
            drpCustomer.SelectedValue = Convert.ToString(Custid);

            if (objSite.Enable == true)
            {
                dropEnable.SelectedValue = "1";
            }
            else
            {
                dropEnable.SelectedValue = "0";
            }
        }
        else
        {
            // Show Message Site Already Exist
            lblErrorMsg.Text = Resources.MessageResource.errSiteExist.ToString();
        }
    }
Exemplo n.º 3
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();
        }
    }