Beispiel #1
0
    protected void ImageButton9_Click(object sender, ImageClickEventArgs e)
    {
        try
        {
            string SQL = "";
            if (TextBox9.Text != "" && TextBox10.Text != "")
            {
                SQL = "Select * from tbl_subname where subname='" + TextBox9.Text.Trim() + "' and subid ='" + TextBox10.Text.Trim() + "'";
            }
            else if (TextBox10.Text != "")
            {
                SQL = "Select * from tbl_subname where subid ='" + TextBox10.Text.Trim() + "'";
            }

            SqlConnection con = new SqlConnection(ConnectAll.ConnectMe());
            con.Open();
            SqlCommand     cmd = new SqlCommand(SQL, con);
            SqlDataAdapter AD  = new SqlDataAdapter(cmd);
            DataSet        DS  = new DataSet();
            AD.Fill(DS);

            GridView2.DataSource = DS;
            GridView2.DataBind();

            TextBox9.Text  = "";
            TextBox10.Text = "";
        }
        catch (Exception ex)
        {
            lblmsg.Visible = true;
            lblmsg.Text    = "Error :" + ex.Message.Trim();
            return;
        }
    }
Beispiel #2
0
    protected void SaveAll()
    {
        string SQL = "INSERT INTO tbl_subname (fname,fid,subname,subid,code)" +
                     " Values (@fname,@fid,@subname,@subid,@code)";

        try
        {
            SqlConnection con = new SqlConnection(ConnectAll.ConnectMe());
            con.Open();
            SqlCommand cmd = new SqlCommand(SQL, con);
            cmd.Parameters.AddWithValue("@fname", SqlDbType.NVarChar).Value   = DropDownList1.SelectedItem.Text.Trim();
            cmd.Parameters.AddWithValue("@fid", SqlDbType.NVarChar).Value     = lblAbrv.Text.Trim();
            cmd.Parameters.AddWithValue("@subname", SqlDbType.NVarChar).Value = TextBox6.Text.Trim();
            cmd.Parameters.AddWithValue("@subid", SqlDbType.NVarChar).Value   = TextBox7.Text.Trim();
            cmd.Parameters.AddWithValue("@code", SqlDbType.NVarChar).Value    = TextBox8.Text.Trim();
            cmd.ExecuteNonQuery();
            con.Close();
            cmd.Dispose();
            CLS();
            Loadgrd();
        }
        catch (Exception ex)
        {
            lblerr.Visible = true;
            lblerr.Text    = "Error :" + ex.Message.Trim();
            return;
        }
    }
Beispiel #3
0
    /// <summary>
    /// Module to store data into sql server
    /// </summary>


    protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
    {
        try
        {
            string        SQL = "INSERT INTO tbl_facility (statename,lga,facname,faclevel,techarea) VALUES (@statename,@lga,@facname,@faclevel,@techarea)";
            SqlConnection con = new SqlConnection(ConnectAll.ConnectMe());
            con.Open();
            SqlCommand cmd = new SqlCommand(SQL, con);
            cmd.Parameters.Add("@statename", SqlDbType.NVarChar).Value = DrpState.SelectedItem.Text.Trim();
            cmd.Parameters.Add("@lga", SqlDbType.NVarChar).Value       = DrpLGA.SelectedItem.Text.Trim();
            cmd.Parameters.Add("@facname", SqlDbType.NVarChar).Value   = TextBox1.Text.Trim();
            cmd.Parameters.Add("@faclevel", SqlDbType.NVarChar).Value  = DrpFacname.SelectedItem.Text.Trim();
            cmd.Parameters.Add("@factype", SqlDbType.NVarChar).Value   = Drpfactype.SelectedItem.Text.Trim();
            cmd.Parameters.Add("@techarea", SqlDbType.NVarChar).Value  = DrpTechArea.SelectedItem.Text.Trim();
            cmd.ExecuteNonQuery();
            cmd.Dispose();
            con.Close();
            Fillgrd();
            CLS();
        }
        catch (Exception ex)
        {
            lblerr.Visible = true;
            lblerr.Text    = "  " + ex.Message.ToString().Trim();
        }
    }
Beispiel #4
0
    public static int ProgramTable(string theTable)
    {
        try
        {
            SqlConnection SC      = new SqlConnection(ConnectAll.ConnectMe());
            string        cmdText = @"IF EXISTS(SELECT * FROM INFORMATION_SCHEMA.TABLES 
                 WHERE TABLE_NAME='" + theTable + "') SELECT 1 ELSE SELECT 0";
            SC.Open();
            SqlCommand DateCheck = new SqlCommand(cmdText, SC);
            int        x         = Convert.ToInt32(DateCheck.ExecuteScalar());
            if (x == 1)
            {
                return(1);
            }
            else
            {
                return(0);
            }

            SC.Close();
        }
        catch (Exception ex)
        {
            return(-1);
        }
    }//===end
    protected void LoaDGrid()
    {
        try
        {
            string    mFile1 = drpProgramArea.SelectedItem.Text.Trim();
            string    mFile  = string.Empty;
            DataTable dt     = new DataTable();

            GetThematic(mFile1, out mFile);

            string        SQL = " SELECT * FROM tbl_defn where grouptype ='" + mFile.Trim() + "'";
            SqlConnection cn  = new SqlConnection(ConnectAll.ConnectMe());
            cn.Open();
            SqlCommand     cmd = new SqlCommand(SQL, cn);
            SqlDataAdapter da  = new SqlDataAdapter(cmd);
            da.Fill(dt);

            GridView1.DataSource = dt;
            GridView1.DataBind();
        }
        catch (Exception ex)
        {
            webMessage.Show("ERROR :" + ex.Message);
            return;
        }
    }
Beispiel #6
0
    protected void Button3_Click(object sender, EventArgs e)
    {
        SqlConnection con = new SqlConnection(ConnectAll.ConnectMe());

        DataSet reportData = new DataSet();
        string  filenames  = FileUpload1.FileName.ToString();

        //Server.MapPath(string.Format("~/{0}/", "XML"))
        string Filename = Server.MapPath(string.Format("~/{0}/", "XML") + filenames);

        reportData.ReadXml(Filename);
        con.Open();

        DataTable dt2 = new DataTable();

        foreach (DataTable dt in reportData.Tables)
        {
            SqlBulkCopy sbc = new SqlBulkCopy(con);

            sbc.DestinationTableName = "tbl_ART";
            foreach (DataColumn dc in dt.Columns)
            {
                sbc.ColumnMappings.Add(dc.ColumnName, dc.ColumnName);
            }// Second Foreach
             //dt2 = dt.DefaultView.ToTable(true);
             //sbc.WriteToServer(dt.DefaultView.ToTable(true));
            dt2 = RemoveDuplicatesRecords(dt);
            sbc.WriteToServer(dt2);
        }// First Foreach
        con.Close();
    }
Beispiel #7
0
    protected void LoadDrp()
    {
        try
        {
            string SQL = "Select * from tbl_grpname order by fname asc";

            SqlConnection con = new SqlConnection(ConnectAll.ConnectMe());
            con.Open();
            SqlCommand    cmd = new SqlCommand(SQL, con);
            SqlDataReader r   = cmd.ExecuteReader();
            DropDownList1.Items.Clear();
            DropDownList1.Items.Add("");
            while (r.Read())
            {
                DropDownList1.Items.Add(r["fname"].ToString());
            }

            r.Dispose();
            cmd.Dispose();
            con.Close();
        }
        catch (Exception ex)
        {
            lblerr.Visible = true;
            lblerr.Text    = "Error :" + ex.Message.Trim();
            return;
        }
    }
Beispiel #8
0
    private void LoadData()
    {
        string        SQl = "Select * from tbl_grpname order by abrv asc";
        SqlConnection cn  = new SqlConnection(ConnectAll.ConnectMe());

        cn.Open();
        SqlCommand    cmd = new SqlCommand(SQl, cn);
        SqlDataReader r   = cmd.ExecuteReader();

        try
        {
            drpProgram.ClearSelection();
            drpProgram.Items.Clear();
            drpProgram.Items.Add("");
            while (r.Read())
            {
                drpProgram.Items.Add(r["fname"].ToString());
            }
        }
        catch (Exception e)
        {
            webMessage.Show("Error :" + e.Message.ToString());
            return;
        }
    }
    protected void FillState()
    {
        string        SQl = "Select Distinct statename from tbl_States order by statename asc";
        SqlConnection cn  = new SqlConnection(ConnectAll.ConnectMe());

        cn.Open();
        SqlCommand    cmd = new SqlCommand(SQl, cn);
        SqlDataReader r   = cmd.ExecuteReader();

        try
        {
            drpStates.ClearSelection();
            drpStates.Items.Clear();
            drpStates.Items.Add("");
            while (r.Read())
            {
                drpStates.Items.Add(r["statename"].ToString());
            }
        }
        catch (Exception e)
        {
            Response.Write("<script language=javascript>alert('" + e.Message.ToString() + "' );</script>");
            return;
        }
    }
    protected void drpStates_SelectedIndexChanged(object sender, EventArgs e)
    {
        string SQL, SQL1 = "";

        if (drpStates.SelectedItem.Text.Trim() == "Ebonyi")
        {
            SQL1 = "Abakaliki";
            SQL  = "SELECT * from tbl_states where capitals ='" + SQL1 + "' order by lga asc";
        }
        else
        {
            SQL = "SELECT * from tbl_states where statename ='" + drpStates.SelectedItem.Text.Trim() + "' order by lga asc";
        }
        SqlConnection cn = new SqlConnection(ConnectAll.ConnectMe());

        cn.Open();
        SqlCommand    cmd = new SqlCommand(SQL, cn);
        SqlDataReader r   = cmd.ExecuteReader();

        try
        {
            drpLGA.ClearSelection();
            drpLGA.Items.Clear();
            drpLGA.Items.Add("");
            while (r.Read())
            {
                drpLGA.Items.Add(r["lga"].ToString());
            }
        }
        catch (Exception ex)
        {
            webMessage.Show("Error Message : " + ex.Message.ToString());
            return;
        }
    }
Beispiel #11
0
    protected void drpProgram_SelectedIndexChanged(object sender, EventArgs e)
    {
        try
        {
            string mFile1 = drpProgram.SelectedItem.Text.Trim();
            string mFile  = string.Empty;

            GetThematic(mFile1, out mFile);

            string        SQL = "SELECT * from tbl_TargetDefine where grouptype ='" + mFile + "'";
            SqlConnection cn  = new SqlConnection(ConnectAll.ConnectMe());
            cn.Open();
            SqlCommand     cmd = new SqlCommand(SQL, cn);
            SqlDataAdapter DA  = new SqlDataAdapter(cmd);
            DataTable      dt  = new DataTable();
            DA.Fill(dt);
            GridView1.DataSource = dt;
            GridView1.DataBind();
        }
        catch (Exception ex)
        {
            webMessage.Show("Error :" + ex.Message.ToString());
            return;
        }
    }
Beispiel #12
0
    }//=== End of EditMe() Method

    protected void ImageButton4_Click(object sender, ImageClickEventArgs e)
    {
        try
        {
            string        SQL = "Delete tbl_facility where facname=@facname";
            SqlConnection con = new SqlConnection(ConnectAll.ConnectMe());
            con.Open();
            SqlCommand cmd = new SqlCommand(SQL, con);
            cmd.Parameters.Add("@statename", SqlDbType.NVarChar).Value = DrpState.Text.Trim();
            cmd.Parameters.Add("@lga", SqlDbType.NVarChar).Value       = DrpLGA.Text.Trim();
            cmd.Parameters.Add("@facname", SqlDbType.NVarChar).Value   = TextBox1.Text.Trim();
            cmd.Parameters.Add("@faclevel", SqlDbType.NVarChar).Value  = DrpFacname.Text.Trim();
            cmd.Parameters.Add("@factype", SqlDbType.NVarChar).Value   = Drpfactype.Text.Trim();
            cmd.Parameters.Add("@techarea", SqlDbType.NVarChar).Value  = DrpTechArea.Text.Trim();
            cmd.ExecuteNonQuery();
            Fillgrd();
            HideText();
            CLS();
        }
        catch (Exception ex)
        {
            lblerr.Visible = true;
            lblerr.Text    = "Error :" + ex.Message;
            return;
        }
    }
Beispiel #13
0
    }///===== End

    void FillstateDp()
    {
        try
        {
            string        sqlstate = "Select distinct statename from tbl_state order by statename asc";
            SqlConnection con      = new SqlConnection(ConnectAll.ConnectMe());
            con.Open();
            SqlCommand    cmd = new SqlCommand(sqlstate, con);
            SqlDataReader r   = cmd.ExecuteReader();
            DrpState.Items.Clear();
            DrpState.Items.Add("");
            drpstate2.Items.Clear();
            drpstate2.Items.Add("");
            while (r.Read())
            {
                DrpState.Items.Add(r["statename"].ToString());
                drpstate2.Items.Add(r["statename"].ToString());
            }

            DrpState.DataBind();
            drpstate2.DataBind();
            con.Close();
            r.Dispose();
        }
        catch (Exception ex)
        {
            lblerr.Visible = true;
            lblerr.Text    = "  " + ex.Message.ToString().Trim();
        }
    }
    protected void FillThematic()
    {
        string        SQl = "Select * from tbl_grpname order by abrv asc";
        SqlConnection cn  = new SqlConnection(ConnectAll.ConnectMe());

        cn.Open();
        SqlCommand    cmd = new SqlCommand(SQl, cn);
        SqlDataReader r   = cmd.ExecuteReader();

        try
        {
            drpProgramArea.ClearSelection();
            drpProgramArea.Items.Clear();
            drpProgramArea.Items.Add("");
            while (r.Read())
            {
                drpProgramArea.Items.Add(r["fname"].ToString());
            }
        }
        catch (Exception e)
        {
            Response.Write("<script language=javascript>alert('" + e.Message.ToString() + "' );</script>");
            return;
        }
    }
Beispiel #15
0
    }//=== End of EditMe() Method

    protected void ImageButton2_Click(object sender, ImageClickEventArgs e)
    {
        string PO = Session["fname"].ToString().Trim();

        string SQL = "Update tbl_grpname set fid=@fid,fname=@fname where fname='" + PO + "'";

        try
        {
            SqlConnection con = new SqlConnection(ConnectAll.ConnectMe());
            con.Open();
            SqlCommand cmd = new SqlCommand(SQL, con);
            cmd.Parameters.AddWithValue("@fid", SqlDbType.NVarChar).Value   = TextBox2.Text.Trim();
            cmd.Parameters.AddWithValue("@fname", SqlDbType.NVarChar).Value = TextBox1.Text.Trim();
            cmd.ExecuteNonQuery();
            CLS();
            Loadgrd();
            con.Close();
            cmd.Dispose();
            PO = null;
        }
        catch (Exception ex)
        {
            lblerr2.Visible = true;
            lblerr2.Text    = "Error :" + ex.Message;
            return;
        }
    }
Beispiel #16
0
    ///========

    protected void ImageButton3_Click(object sender, ImageClickEventArgs e)
    {
        string SQL = "";

        try
        {
            if (TextBox1.Text != "" && TextBox2.Text != "")
            {
                SQL = "Delete tbl_grpname where fname ='" + TextBox1.Text.Trim() + "' and fid='" + TextBox2.Text.Trim() + "'";
            }
            else if (TextBox2.Text != "")
            {
                SQL = "Delete tbl_grpname where fid ='" + TextBox2.Text.Trim() + "'";
            }
            SqlConnection con = new SqlConnection(ConnectAll.ConnectMe());
            con.Open();
            SqlCommand cmd = new SqlCommand(SQL, con);
            cmd.Parameters.AddWithValue("@fname", SqlDbType.NVarChar).Value = TextBox1.Text.Trim();
            cmd.Parameters.AddWithValue("@fid", SqlDbType.NVarChar).Value   = TextBox2.Text.Trim();
            cmd.ExecuteNonQuery();
            con.Close();
            Loadgrd();
            CLS();
            ImageButton2.Visible = false;
        }
        catch (Exception ex)
        {
            lblerr.Visible = true;
            lblerr.Text    = "Error " + ex.Message.ToString().Trim();
            return;
        }
    }
Beispiel #17
0
//======== End

    protected void EditMe(string SuppID)
    {
        if (SuppID == null)
        {
            return;
        }

        string KK = "Select * from tbl_facility Where num='" + Convert.ToString(SuppID) + "'";

        using (SqlConnection p = new SqlConnection(ConnectAll.ConnectMe()))
        {
            p.Open();
            SqlCommand Cmd = new SqlCommand(KK, p);

            try
            {
                //DataRow dr = ConnectAll.GetDataRow(KK); // ===== Get the datarow from a generic method in a classs
                SqlDataReader dr = Cmd.ExecuteReader(CommandBehavior.CloseConnection);
                while (dr.Read())
                {
                    if (dr != null)
                    {
                        TextBox3.Visible = true;
                        TextBox4.Visible = true;
                        TextBox5.Visible = true;
                        TextBox6.Visible = true;
                        TextBox7.Visible = true;

                        //DrpState.Items.Clear();
                        //ListItem newItem = new ListItem();
                        //newItem.Text = dr["statename"].ToString();
                        //DrpState.Text = dr["statename"].ToString();

                        TextBox3.Text = dr["statename"].ToString();
                        TextBox4.Text = dr["lga"].ToString();
                        TextBox1.Text = dr["facname"].ToString();
                        TextBox5.Text = dr["faclevel"].ToString();
                        TextBox6.Text = dr["factype"].ToString();
                        TextBox7.Text = dr["techarea"].ToString();
                    }
                }

                ImageButton2.Visible         = true;
                TabContainer1.ActiveTabIndex = 0;
            }
            catch (Exception ex)
            {
                lblerr2.Visible = true;
                lblerr2.Text    = "Error :" + ex.Message;
                return;
            }
            finally
            {
                p.Close();
                Cmd.Dispose();
                //MultiView1.ActiveViewIndex = 0
            }
        }
    }//=== End of EditMe() Method
Beispiel #18
0
    protected DataTable GetDatafromDatabase()
    {
        DataTable dt = new DataTable();

        using (SqlConnection con = new SqlConnection(ConnectAll.ConnectMe()))
        {
            con.Open();
            SqlCommand     cmd = new SqlCommand("Select * from VW_htc", con); // "Select TOP 10 UserName,LastName,Location FROM UserInformation", con);
            SqlDataAdapter da  = new SqlDataAdapter(cmd);
            da.Fill(dt);
            con.Close();
        }
        return(dt);
    }
Beispiel #19
0
    protected void EditMe(string SuppID)
    {
        if (SuppID == null)
        {
            return;
        }
        Session["fname"] = null;

        string KK = "Select * from tbl_subname Where num='" + Convert.ToString(SuppID) + "'";

        using (SqlConnection p = new SqlConnection(ConnectAll.ConnectMe()))
        {
            p.Open();
            SqlCommand Cmd = new SqlCommand(KK, p);

            try
            {
                DataRow dr = ConnectAll.GetDataRow(KK); // ===== Get the datarow from a generic method in a classs
                if (dr != null)
                {
                    DropDownList1.Text = dr["fname"].ToString();
                    lblAbrv.Text       = dr["fid"].ToString();
                    TextBox6.Text      = dr["subname"].ToString();
                    TextBox7.Text      = dr["subid"].ToString();
                    TextBox8.Text      = dr["code"].ToString();


                    Session["fname"] = dr["fname"].ToString();
                    CLS2();
                }
                ImageButton6.Visible         = true;
                ImageButton8.Visible         = true;
                TabContainer1.ActiveTabIndex = 0;
                GridView2.DataSource         = null;
                GridView2.DataBind();
            }
            catch (Exception ex)
            {
                lblmsg.Visible = true;
                lblmsg.Text    = "  " + ex.Message.ToString().Trim();
                return;
            }
            finally
            {
                p.Close();
                Cmd.Dispose();
                //MultiView1.ActiveViewIndex = 0
            }
        }
    }//=== End of EditMe() Method
    }//===== End

    protected void LoadGrd()
    {
        string        SQL = "SELECT * FROM tbl_DataElems";
        SqlConnection con = new SqlConnection(ConnectAll.ConnectMe());

        con.Open();
        SqlCommand     cmd = new SqlCommand(SQL, con);
        SqlDataAdapter da  = new SqlDataAdapter(cmd);
        DataSet        ds  = new DataSet();

        da.Fill(ds);
        GridView1.DataSource = ds;
        GridView1.DataBind();
    }
Beispiel #21
0
    //IF TABLE tbl_TempReport IF FOUND DROP IT AND RECREATE IT
    private void LoadThematic()
    {
        string    m_code;
        string    m_descrip;
        object    m_value;
        string    m_grouptype;
        DataTable dt = GetDatafromDatabase();

        // My own Testing Code
        foreach (DataColumn dc in dt.Columns)
        {
            foreach (DataRow dr in dt.Rows)
            {
                string SQL = "Select * from tbl_defn where code='" + dc.ToString().Trim() + "'";  // and grouptype = 'htc'";
                using (SqlConnection cn = new SqlConnection(ConnectAll.ConnectMe()))
                {
                    if (cn.State == ConnectionState.Closed)
                    {
                        cn.Open();
                    }
                    SqlCommand    cmd = new SqlCommand(SQL, cn);
                    SqlDataReader rd  = cmd.ExecuteReader();

                    while (rd.Read())
                    {
                        m_code      = dc.ToString();
                        m_descrip   = rd["description"].ToString();
                        m_value     = dr.ToString();
                        m_grouptype = rd["grouptype"].ToString();
                        rd.Close();
                        //pass the code and description and value to the reporting table
                        string sqlIN = "INSERT INTO tbl_TempReport (code,descrip,value,grouptype) VALUES(@code,@descrip,@value,@grouptype)";
                        if (cn.State == ConnectionState.Closed)
                        {
                            cn.Open();
                        }
                        SqlCommand cmdIN = new SqlCommand(sqlIN, cn);
                        cmdIN.Parameters.AddWithValue("@code", SqlDbType.NVarChar).Value      = m_code;
                        cmdIN.Parameters.AddWithValue("@descrip", SqlDbType.NVarChar).Value   = m_descrip;
                        cmdIN.Parameters.AddWithValue("@value", SqlDbType.Int).Value          = m_value;
                        cmdIN.Parameters.AddWithValue("@grouptype", SqlDbType.NVarChar).Value = m_grouptype;
                        cmdIN.ExecuteNonQuery();
                        // names = rd["description"].ToString();
                    }
                }
                /// ChkLoadData(dr, dc.ColumnName);
            }
        }
    }
 protected void Fillgrd()
 {
     try
     {
         string        SQL = "Select * from tbl_facility";
         SqlConnection con = new SqlConnection(ConnectAll.ConnectMe());
         con.Open();
         SqlCommand cmd = new SqlCommand(SQL, con);
     }
     catch (Exception ex)
     {
         ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert(' Facility " + ex.Message.ToString() + "';", true);
         return;
     }
 }
    private void TableCreate()
    {
        try
        {
            Object        I;
            SqlConnection cn = new SqlConnection(ConnectAll.ConnectMe());
            SqlCommand    cmd;
            if (FindTable.ProgramTable("tbl_TargetDefine") == 1)
            {
                return;
            }
            else
            {
                string sqlCreate1 = "CREATE TABLE tbl_TargetDefine ( ID int IDENTITY(1,1) NOT NULL,";
                sqlCreate1 += "Grouptype Nvarchar(50) Null, Code Nvarchar(50) Null, Description Nvarchar(2000) Null)ON [PRIMARY] ";
                if (cn.State == ConnectionState.Closed)
                {
                    cn.Open();
                }
                cmd = new SqlCommand(sqlCreate1, cn);
                I   = cmd.ExecuteScalar();
                cmd.Dispose();
                cn.Close();
            }
            if (FindTable.ProgramTable("tbl_TargetAssin") == 1)
            {
                return;
            }
            else
            {
                string sqlCreate2 = "CREATE TABLE tbl_TargetAssin ( ID int IDENTITY(1,1) NOT NULL,";
                sqlCreate2 += "Grouptype Nvarchar(50) Null, Code Nvarchar(50) Null, Description Nvarchar(2000) Null,";
                sqlCreate2 += "mYears nvarchar(20) Null, Months Nvarchar(20) Null, TargetValue Int)ON [PRIMARY] ";

                if (cn.State == ConnectionState.Closed)
                {
                    cn.Open();
                }
                cmd = new SqlCommand(sqlCreate2, cn);
                I   = cmd.ExecuteScalar();
                cmd.Dispose();
                cn.Close();
            }
        }catch (Exception ex)
        {
            webMessage.Show("Error Creating Report Table :" + ex.Message);
        }
    }
    protected void CreateXML(string TblName)
    {
        #region how to create and delete directory

        //string directoryPath = Server.MapPath(string.Format("~/{0}/", txtFolderName.Text.Trim()));
        //if (!Directory.Exists(directoryPath))
        //{
        //    Directory.CreateDirectory(directoryPath);
        //}
        //else
        //{
        //    ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert('Directory already exists.');", true);
        //}
        //=============================================================================================
        //string directoryPath = Server.MapPath(string.Format("~/{0}/", txtFolderName.Text.Trim()));
        //if (Directory.Exists(directoryPath))
        //{
        //    Directory.Delete(directoryPath);
        //}
        //else
        //{
        //    ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert('Directory does not exist.');", true);
        //}

        #endregion

        try
        {
            string        mName  = TextBox15.Text.Trim() + "_" + TblName.Trim() + "_" + ComboBox1.SelectedItem.Text + "_" + DateTime.Now.Year.ToString();
            SqlConnection con    = new SqlConnection(ConnectAll.ConnectMe());
            string        strSQL = "Select * from " + TblName.Trim();



            SqlDataAdapter dt = new SqlDataAdapter(strSQL, con);

            DataSet ds = new DataSet();

            dt.Fill(ds, TblName.Trim());

            ds.WriteXml(@"C:\PPMExpress\XML\" + mName + ".xml");
        }
        catch (Exception ex)
        {
            Response.Write("<script language=javascript>alert('" + TblName.Trim() + " " + ex.Message.ToString() + "');</script>");
            return;
        }
    }
Beispiel #25
0
 private void CREATTable()
 {
     try
     {
         string SQLT = "CREATE TABLE tbl_TempReport ( GROUPTYPE NVARCHAR(50),code NVARCHAR(50), DESCRIP NVARCHAR(MAX),VALUEP NVARCHAR(50))";
         int    done = 0;
         using (SqlConnection cn = new SqlConnection(ConnectAll.ConnectMe()))
         {
             cn.Open();
             SqlCommand cmd = new SqlCommand(SQLT, cn);
             done = cmd.ExecuteNonQuery();
         }
     }catch (Exception ex)
     {
         webMessage.Show("Error check for temp table :" + ex.Message);
     }
 }
Beispiel #26
0
    public static void InsertTempReport(string GroupType, string Code, string Desc)
    {
        var Dat = new DataTable();

        using (SqlConnection cn = new SqlConnection(ConnectAll.ConnectMe()))
        {
            cn.Open();
            SqlCommand cmd = new SqlCommand();
            cmd.CommandText = "sp_InsertTempReport";
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Connection  = cn;
            cmd.Parameters.AddWithValue("@grouptype", SqlDbType.NVarChar).Value = GroupType;
            cmd.Parameters.AddWithValue("@code", SqlDbType.NVarChar).Value      = Code;
            cmd.Parameters.AddWithValue("@descrip", SqlDbType.NVarChar).Value   = Desc;
            cmd.ExecuteNonQuery();
        }
    }
 protected void ImageButton3_Click(object sender, ImageClickEventArgs e)
 {
     try
     {
         string        sql = "DELETE tbl_States where statename ='" + TextBox1.Text.Trim() + "'";
         SqlConnection con = new SqlConnection(ConnectAll.ConnectMe());
         con.Open();
         SqlCommand cmd = new SqlCommand(sql, con);
         cmd.ExecuteNonQuery();
         cmd.Dispose();
         con.Close();
     }
     catch (Exception ex)
     {
         LblErr.Visible = true;
         LblErr.Text    = "Can not Erase this document.....: " + ex.Message.ToString().Trim();
     }
 }
 private void DropTable()
 {
     try
     {
         string SQLT = "drop table tbl_TempReport";
         int    done = 0;
         using (SqlConnection cn = new SqlConnection(ConnectAll.ConnectMe()))
         {
             cn.Open();
             SqlCommand cmd = new SqlCommand(SQLT, cn);
             done = cmd.ExecuteNonQuery();
         }
     }
     catch (Exception ex)
     {
         webMessage.Show("Error check for temp table :" + ex.Message);
     }
 }
Beispiel #29
0
    public static DataTable SearchTableDefine(string mFile)
    {
        var Dat = new DataTable();

        using (SqlConnection cn = new SqlConnection(ConnectAll.ConnectMe()))
        {
            cn.Open();
            SqlCommand cmd = new SqlCommand();
            cmd.CommandText = "sp_SearchTableDefine";
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Connection  = cn;
            cmd.Parameters.AddWithValue("@mFile", SqlDbType.NVarChar).Value = mFile;
            var sda = new SqlDataAdapter();
            sda.SelectCommand = cmd;
            sda.Fill(Dat);
            return(Dat);
        }
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        try
        {
            //==== Create SQL Table for storage
            TableCreate();

            foreach (GridViewRow row in GridView1.Rows)
            {
                //===== Accessing the checkbox
                CheckBox cb = (CheckBox)row.FindControl("ChkSelect");

                if (cb != null && cb.Checked)
                {
                    int ID = Convert.ToInt32(GridView1.DataKeys[row.RowIndex].Value);

                    //== Search for the records and store in datatbase
                    string        SQLP = "SELECT * FROM tbl_defn where ID ='" + Convert.ToString(ID) + "'";
                    SqlConnection cn   = new SqlConnection(ConnectAll.ConnectMe());
                    cn.Open();
                    SqlCommand    cmd1 = new SqlCommand(SQLP, cn);
                    SqlDataReader r    = cmd1.ExecuteReader();
                    while (r.Read())
                    {
                        string SQL = "INSERT INTO tbl_TargetDefine (grouptype,code,description) VALUES(@grouptype,@code,@description)";
                        if (cn.State == ConnectionState.Closed)
                        {
                            cn.Open();
                        }
                        SqlCommand cmd = new SqlCommand(SQL, cn);
                        cmd.Parameters.AddWithValue("@code", SqlDbType.NVarChar).Value        = r["code"].ToString();
                        cmd.Parameters.AddWithValue("@description", SqlDbType.NVarChar).Value = r["description"].ToString();
                        cmd.Parameters.AddWithValue("@grouptype", SqlDbType.NVarChar).Value   = r["grouptype"].ToString();
                        cmd.ExecuteReader();
                    }
                }
            }
        }
        catch (Exception ex)
        {
            webMessage.Show("ERROR :" + ex.Message.ToString());
            return;
        }
    }