Ejemplo n.º 1
0
    protected void BtnSave_Click(object sender, EventArgs e)
    {
        System.Text.StringBuilder sb = new System.Text.StringBuilder();
        try
        {
            string motif = string.Empty;

            string strmsg = "";
            objFocalPoints.FocalPointsID     = 0;
            objFocalPoints.FocalPointsUser   = int.Parse(ddlUsers.SelectedValue);
            objFocalPoints.FocalPointsSector = int.Parse(ddlSectorInterest.SelectedValue);
            objFocalPoints.FocalPointsArea   = int.Parse(ddlAreaInterest.SelectedValue);
            objFocalPoints.LastModifiedBy    = int.Parse(Session[RunningCache.UserID].ToString());
            objFocalPoints.LastModifiedDate  = DateTime.Now;
            if (RadioButtonYes.Checked == true)
            {
                objFocalPoints.FocalPointsNotification = true;
            }
            else if (RadioButtonNo.Checked == true)
            {
                objFocalPoints.FocalPointsNotification = false;
            }

            if (BtnSave.Text.ToUpper() == "Save".ToUpper())
            {
                DataTable dtFP = objFocalPoints.GetFocalPoints(" where FocalPointsUser="******" and FocalPointsSector=" + int.Parse(ddlSectorInterest.SelectedValue) + " and FocalPointsArea=" + int.Parse(ddlAreaInterest.SelectedValue));
                if (dtFP.Rows.Count > 0)
                {
                    if (this.global_success.Visible)
                    {
                        this.global_success.Visible = false;
                    }
                    this.global_error.Visible  = true;
                    this.global_error_msg.Text = " This user is already a Focal Point for the Sector and Area selected";
                    UpdatePanel.Update();


                    UpdatePanel.Update();
                }
                else
                {
                    objFocalPoints.SaveFocalPoints(objFocalPoints, out strmsg);
                    if (this.global_error.Visible)
                    {
                        this.global_error.Visible = false;
                    }
                    this.global_success.Visible  = true;
                    this.global_success_msg.Text = "The Focal Point is successfully saved into the system.";
                    UpdatePanel.Update();
                }
            }


            else if (BtnSave.Text.ToUpper() == "UPDATE".ToUpper())
            {
                objFocalPoints.FocalPointsID = int.Parse(Session[RunningCache.FocalPointsID].ToString());
                objFocalPoints.UpdateFocalPoints(objFocalPoints, out strmsg);
                this.global_success.Visible  = true;
                this.global_success_msg.Text = "The Focal Point is successfully updated into the system.";
                UpdatePanel.Update();
            }

            upCrudGrid.Update();
            bindgrid();
        }

        catch (Exception ex)
        {
        }


        sb.Append(@"<script type='text/javascript'>");

        sb.Append("$('#addEdiModal').modal('hide');");

        sb.Append(@"</script>");

        ToolkitScriptManager.RegisterClientScriptBlock(this, this.GetType(), "EditHideModalScript", sb.ToString(), false);
    }