protected void btn_add_Click(object sender, EventArgs e)
    {
        try
        {
            ds_analytics.projectsDataTable prj_dt  = new ds_analytics.projectsDataTable();
            ds_analytics.projectsRow       prj_row = prj_dt.NewprojectsRow();

            prj_row.projectname     = tb_prj_name.Text;
            prj_row.projecttype     = ddl_prj_type.SelectedItem.Text;
            prj_row.projectcategory = ddl_prj_category.SelectedItem.Text;
            prj_row.projectbrand    = ddl_prj_brand.SelectedItem.Text;
            if (tb_prj_start.Text == "")
            {
                prj_row.SetcreatedateNull();
            }
            else
            {
                prj_row.createdate = Convert.ToDateTime(tb_prj_start.Text);
            }
            if (tb_prj_end.Text == "")
            {
                prj_row.SetcompletiondateNull();
            }
            else
            {
                prj_row.completiondate = Convert.ToDateTime(tb_prj_end.Text).AddHours(23).AddMinutes(59).AddSeconds(59);
            }
            if (tb_prj_budget.Text == "")
            {
                prj_row.SetbudgetNull();
            }
            else
            {
                prj_row.budget = Convert.ToDouble(tb_prj_budget.Text);
            }
            prj_row.isactive = cb_isactive.Checked;

            projects.insert(prj_row);

            string url = "projects.aspx";
            ClientScript.RegisterStartupScript(this.GetType(), "callfunction", "alert('Record Added Successfully.');window.location.href = '" + url + "';", true);
        }
        catch (Exception ex)
        {
            ClientScript.RegisterStartupScript(this.GetType(), "error", "<script>alert('Error in adding record.');</script>");
        }
    }
    protected void btn_update_Click(object sender, EventArgs e)
    {
        ds_analytics.projectsRow prj_row = ((ds_analytics.projectsRow)(ViewState["prj_row"]));
        prj_row.projectname     = tb_prj_name.Text;
        prj_row.projecttype     = ddl_prj_type.SelectedItem.Text;
        prj_row.projectcategory = ddl_prj_category.SelectedItem.Text;
        prj_row.projectbrand    = ddl_prj_brand.SelectedItem.Text;
        if (tb_prj_start.Text == "")
        {
            prj_row.SetcreatedateNull();
        }
        else
        {
            prj_row.createdate = Convert.ToDateTime(tb_prj_start.Text);
        }
        if (tb_prj_end.Text == "")
        {
            prj_row.SetcompletiondateNull();
        }
        else
        {
            prj_row.completiondate = Convert.ToDateTime(tb_prj_end.Text).AddHours(23).AddMinutes(59).AddSeconds(59);
        }
        if (tb_prj_budget.Text == "")
        {
            prj_row.SetbudgetNull();
        }
        else
        {
            prj_row.budget = Convert.ToDouble(tb_prj_budget.Text);
        }
        prj_row.isactive = cb_isactive.Checked;

        projects.update(prj_row);

        ds_analytics.projectsDataTable prj_dt = projects.getAllProjects();
        gv_projects.DataSource = prj_dt;
        gv_projects.DataBind();
        ViewState["dtStored"] = prj_dt;

        Reset();
    }