Exemplo n.º 1
0
    protected void btnAdd_Click(object sender, EventArgs e)
    {
        if (string.IsNullOrEmpty(lblSelectedClient.Text))
        {
            ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "select client", "alert('Please select client from list')", true);
            return;
        }
        string platform;

        if (ddlPlatform.SelectedIndex == 0)
        {
            if (string.IsNullOrEmpty(txtPlatform.Text.Trim()))
            {
                ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "select platform", "alert('Please select platform')", true);
                return;
            }
            else
            {
                platform = txtPlatform.Text.Trim();
            }
        }
        else
        {
            platform = ddlPlatform.SelectedItem.Text;
        }

        string jobcode    = lbljl0.Text.Trim() + " => " + lblSelectedClient.Text.Trim();
        string clientname = lblSelectedClient.Text.Trim();

        dt = new DataTable();
        dt = objAccount.CheckJobCode(jobcode, ddlTeam.SelectedValue);
        if (dt.Rows.Count > 0)
        {
            ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "Client exist", "alert('Client already exist')", true);
            return;
        }
        bool result = objAccount.AddNewClient(ddlTeam.SelectedValue, clientname, jobcode, ddlPlatform.SelectedValue, lblCode.Text, Session["UID"].ToString());

        if (result == true)
        {
            ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "Success", "alert('Client added successfully please sync RTM to reflect the new client')", true);
            ddlPlatform.SelectedIndex = 0;
            //ddlTeam.SelectedIndex = 0;
            lblSelectedClient.Text = string.Empty;
            lblCode.Text           = string.Empty;
            lbljl0.Text            = string.Empty;
        }
        else
        {
            ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "failed", "alert('Failed.. Please try again')", true);
        }
    }
Exemplo n.º 2
0
    private void SaveClient()
    {
        try
        {
            if (ddlTeam.SelectedIndex == 0)
            {
                lblError.Text      = "Select Team";
                lblError.ForeColor = Color.Red;
                return;
            }
            if (ddlCore.SelectedIndex == 0)
            {
                lblError.Text      = "Select Core Platform";
                lblError.ForeColor = Color.Red;
                return;
            }
            if (string.IsNullOrWhiteSpace(txtClientName.Text))
            {
                lblError.Text      = "Enter client name";
                lblError.ForeColor = Color.Red;
                return;
            }
            if (string.IsNullOrWhiteSpace(txtJobCode.Text))
            {
                lblError.Text      = "Enter job code";
                lblError.ForeColor = Color.Red;
                return;
            }
            if (string.IsNullOrWhiteSpace(txtCode.Text))
            {
                lblError.Text      = "Enter Code";
                lblError.ForeColor = Color.Red;
                return;
            }
            string clientname;
            int    index = txtClientName.Text.IndexOf("›");
            if (index > 0)
            {
                clientname = txtClientName.Text.Substring(index + 1).TrimStart().Trim();
            }
            else
            {
                clientname = txtClientName.Text.TrimStart().Trim();
            }

            string jobcode = txtJobCode.Text.Replace("›", "=>").TrimStart().Trim();

            dt = new DataTable();
            dt = objAccount.CheckJobCode(jobcode, ddlTeam.SelectedValue);
            if (dt.Rows.Count > 0)
            {
                lblError.Text      = "Job Code already exist";
                lblError.ForeColor = Color.Red;
                return;
            }
            else
            {
                bool result = objAccount.AddNewClient(ddlTeam.SelectedValue, clientname, jobcode, ddlCore.SelectedValue, txtCode.Text, Session["UID"].ToString());
                if (result == true)
                {
                    lblError.Text         = "Client added Successfully";
                    lblError.ForeColor    = Color.Blue;
                    ddlCore.SelectedIndex = 0;
                    //ddlTeam.SelectedIndex = 0;
                    txtClientName.Text = string.Empty;
                    txtCode.Text       = string.Empty;
                    txtJobCode.Text    = string.Empty;
                    BindGrid();
                }
                else
                {
                    lblError.Text      = "Something went wrong.. Please try again";
                    lblError.ForeColor = Color.Red;
                }
            }
        }
        catch (Exception ex)
        {
            lblError.Text      = ex.Message;
            lblError.ForeColor = Color.Red;
        }
    }