protected void DetailsView2_ItemInserting(object sender, DetailsViewInsertEventArgs e)
        {
            SqlDataSource6.InsertParameters["semesterID"].DefaultValue = GridView1.SelectedValue.ToString();
            SqlDataSource6.InsertParameters["moduleCode"].DefaultValue = ((DropDownList)DetailsView2.Rows[1].Cells[1].FindControl("DropDownList6")).SelectedValue;

            SqlDataSource6.InsertParameters["lecturerName"].DefaultValue = ((TextBox)DetailsView2.Rows[2].Cells[1].FindControl("TextBox1")).Text;
            SqlDataSource6.Insert();

            Session["selectedSemester"] = GridView1.SelectedValue;
        }
Exemplo n.º 2
0
    protected void btn2_Click(object sender, EventArgs e)
    {
        String Year = DropDownList1.SelectedValue;
        String sqlx = "SELECT DISTINCT UnitType FROM SchoolTable WHERE Year='" + Year + "'";

        SqlDataSource1.SelectCommand = sqlx;
        DataView dv = (DataView)SqlDataSource1.Select(new DataSourceSelectArguments());

        for (int i = 0; i < dv.Count; i++)
        {
            String uType = (String)dv[i][0];
            String Sql   = "select count(UnitName) from SchoolTable where UnitType='" + uType + "' AND Year='" + Year + "' AND Status='Activated'";
            SqlDataSource2.SelectCommand = Sql;
            DataView dv1   = (DataView)SqlDataSource2.Select(new DataSourceSelectArguments());
            int      uName = (int)dv1[0][0];
            String   msqlx = "select count(StudFullName) from StudentTable where UnitType='" + uType + "' AND Year='" + Year + "' AND Status='Activated'";
            SqlDataSource3.SelectCommand = msqlx;
            DataView dv2   = (DataView)SqlDataSource3.Select(new DataSourceSelectArguments());
            int      sName = (int)dv2[0][0];
            float    rf    = float.Parse(txtEnterRegistrationFeesForStudent.Text);
            float    t1    = sName * rf;
            String   msql  = "select count(FullName) from UnitLeaderTable where UnitType='" + uType + "' AND Year='" + Year + "' AND SupportingLeader='false' AND Status='Activated'";
            SqlDataSource4.SelectCommand = msql;
            DataView dv3    = (DataView)SqlDataSource4.Select(new DataSourceSelectArguments());
            int      ulName = (int)dv3[0][0];
            String   msqlv  = "select count(FullName) from UnitLeaderTable where UnitType='" + uType + "' AND Year='" + Year + "' AND SupportingLeader='true' AND Status='Activated'";
            int      sut;
            DataView dv4 = (DataView)SqlDataSource5.Select(new DataSourceSelectArguments());
            if (dv4.Count == 1)
            {
                sut = (int)dv4[0][0];
            }
            else
            {
                sut = 0;
            }

            float  urs    = float.Parse(txtEnterFeesForUnitLeader.Text);
            float  total  = (ulName + sut) * urs;
            int    mtotal = sName + ulName + sut;
            float  rtotal = t1 + total;
            String query  = "INSERT INTO UnitInformation (UnitType, TotalUnits, TotalStudent, StudentRegistrationFees, StudentTotalFees, TotalUnitLeader, TotalSupportingLeader, UnitLeaderRegistrationFees, UnitLeaderTotalFees, TotalMembers, TotalFees, Year)  VALUES('" + uType + "'," + uName + "," + sName + "," + rf + "," + t1 + "," + ulName + "," + sut + "," + urs + "," + total + "," + mtotal + "," + rtotal + ",'" + Year + "')";
            SqlDataSource6.InsertCommand = query;
            int n = SqlDataSource6.Insert();
        }
        Response.Write("<script>alert('Data inserted successfully...')</script>");
        CleartextBoxes(this);
    }
        protected void DetailsView2_ItemInserting(object sender, DetailsViewInsertEventArgs e)
        {
            try
            {
                SqlDataSource6.InsertParameters["semesterID"].DefaultValue = GridView1.SelectedValue.ToString();


                SqlDataSource6.InsertParameters["moduleCode"].DefaultValue = ((DropDownList)DetailsView2.Rows[1].Cells[1].FindControl("DropDownList6")).SelectedValue;

                SqlDataSource6.InsertParameters["lecturerName"].DefaultValue = ((TextBox)DetailsView2.Rows[2].Cells[1].FindControl("TextBox1")).Text;
                SqlDataSource6.Insert();

                Session["selectedSemester"] = GridView1.SelectedValue;
            }
            catch (Exception er)
            {
                ClientScript.RegisterStartupScript(this.GetType(), "", "alert('Select a semester!')", true);
            }
        }
Exemplo n.º 4
0
    protected void btn2_Click(object sender, EventArgs e)
    {
        String Year = DropDownList1.SelectedValue;
        String sqlx = "SELECT DISTINCT UnitType FROM SchoolTable WHERE Year='" + Year + "'";

        SqlDataSource1.SelectCommand = sqlx;
        DataView ds = (DataView)SqlDataSource1.Select(new DataSourceSelectArguments());

        for (int a = 0; a < ds.Count; a++)
        {
            String uType = (String)ds[a][0];
            String Sql   = "select UnitName from SchoolTable where UnitType='" + uType + "' AND Year='" + Year + "' AND CharterNo IS NOT NULL AND Checked IS NULL";
            SqlDataSource2.SelectCommand = Sql;
            DataView dv = (DataView)SqlDataSource2.Select(new DataSourceSelectArguments());
            for (int i = 0; i < dv.Count; i++)
            {
                String uName = (String)dv[i][0];
                String msql  = "select count(StudFullName) from StudentTable where UnitName='" + uName + "' AND Year='" + Year + "'";
                String msqlx = "select count(FullName) from UnitLeaderTable where UnitName='" + uName + "' AND Year='" + Year + "'";
                SqlDataSource3.SelectCommand = msql;
                SqlDataSource4.SelectCommand = msqlx;
                DataView dv1   = (DataView)SqlDataSource3.Select(new DataSourceSelectArguments());
                DataView dv2   = (DataView)SqlDataSource4.Select(new DataSourceSelectArguments());
                int      st    = (int)dv1[0][0];
                int      ut    = (int)dv2[0][0];
                int      total = st + ut;
                int      cal   = st * (int.Parse(txtEnterTotalFeesForStudent.Text) - int.Parse(txtEnterOfficeContributionForStudent.Text)) + ut * (int.Parse(txtEnterTotalFeesForUnitLeader.Text) - int.Parse(txtEnterOfficeContributionForUnitLeader.Text));
                String   query = "INSERT INTO Confirmation (UnitName, Students, UnitLeader, Total, TotalRs, Year, UnitType, Checked) VALUES('" + uName + "'," + st + "," + ut + "," + total + "," + cal + ",'" + Year + "','" + uType + "', 'False')";
                SqlDataSource6.InsertCommand = query;
                try
                {
                    int n = SqlDataSource6.Insert();
                }
                catch (Exception er)
                {
                    Response.Write(er);
                }
            }
        }
        Response.Write("<script>alert('Data inserted successfully...')</script>");
        CleartextBoxes(this);
    }
        //protected void  insertButton_click()
        //{
        //    try
        //    {
        //        SqlDataSource6.InsertParameters["semesterID"].DefaultValue = GridView1.SelectedValue.ToString();


        //        SqlDataSource6.InsertParameters["moduleCode"].DefaultValue = ((DropDownList)DetailsView2.Rows[1].Cells[1].FindControl("DropDownList6")).SelectedValue;

        //        SqlDataSource6.InsertParameters["lecturerName"].DefaultValue = ((TextBox)DetailsView2.Rows[2].Cells[1].FindControl("TextBox1")).Text;
        //        SqlDataSource6.Insert();

        //        Session["selectedSemester"] = GridView1.SelectedValue;
        //    }
        //    catch (Exception er)
        //    {
        //        ClientScript.RegisterStartupScript(this.GetType(), "", "alert('Select a semester')", true);
        //    }
        //    GridView2.Visible = true;
        //    this.setGriview2(GridView1.SelectedValue.ToString());
        //    DetailsView2.DataBind();
        //    UpdatePanel3.Update();
        //}

        protected void insertButton_click(object sender, EventArgs e)
        {
            try
            {
                SqlDataSource6.InsertParameters["semesterID"].DefaultValue = GridView1.SelectedValue.ToString();


                SqlDataSource6.InsertParameters["moduleCode"].DefaultValue = ((DropDownList)DetailsView2.Rows[1].Cells[1].FindControl("DropDownList6")).SelectedValue;

                SqlDataSource6.InsertParameters["lecturerName"].DefaultValue = ((TextBox)DetailsView2.Rows[2].Cells[1].FindControl("TextBox1")).Text;
                SqlDataSource6.Insert();

                Session["selectedSemester"] = GridView1.SelectedValue;
            }
            catch (Exception er)
            {
                ClientScript.RegisterStartupScript(this.GetType(), "", "alert('Select a semester')", true);
            }
            GridView2.Visible = true;
            this.setGriview2(GridView1.SelectedValue.ToString());
            DetailsView2.DataBind();
            UpdatePanel3.Update();
        }