protected void Imagefilter_Click(object sender, ImageClickEventArgs e)
        {
            //Defect = this.Session["DefectID11"].ToString();
            string trteradataconnection = "Data Source='204.99.34.21';User ID='coebatch';Password='******';";

            Teradata.Client.Provider.TdConnection tereconnection = new Teradata.Client.Provider.TdConnection(trteradataconnection);

            string defectid = TxtDefectSearch.Text;

            // int defect = Convert.ToInt32(defectid);


            try
            {
                tereconnection.Open();
                TdDataAdapter AdvancedDefectSearch =
                    new TdDataAdapter(@"select Defectid,Defectname,sdate as OpenDate,Status,Scycle as Cycles,Project,Tester,Module,Assignedto,Closedate as LastUpdatedDate from coebatch.tbl_Defect where CAST(defectid AS VARCHAR(8)) LIKE '%" + defectid + "%' order by Defectid asc ", tereconnection);

                // IDataSource dt1 = new IDataSource ;


                DataSet ds = new DataSet();

                AdvancedDefectSearch.Fill(ds);


                this.GridView1.DataSource = ds.Tables[0];
                GridView1.DataKeyNames    = new string[] { "Defectid" };
                this.GridView1.DataBind();
            }

            catch (Teradata.Client.Provider.TdException ex)
            {
                //Throw the exception to calling environment
                throw ex;
            }
            finally
            {
                //Close the Connection from the Database
                tereconnection.Close();;
            }
        }
Beispiel #2
0
        private void button1_Click(object sender, EventArgs e)
        {
            Stopwatch sw = new Stopwatch();

            sw.Start();
            Teradata.Client.Provider.TdConnection mainConn      = new Teradata.Client.Provider.TdConnection();
            TdConnectionStringBuilder             stringBuilder = new TdConnectionStringBuilder();

            stringBuilder.CommandTimeout    = 300;
            stringBuilder.ConnectionTimeout = 100;
            stringBuilder.DataSource        = host;
            stringBuilder.UserId            = uid;
            stringBuilder.Password          = pwd;
            mainConn.ConnectionString       = stringBuilder.ConnectionString;
            this.Text = host;
            mainConn.Open();


            StreamReader gperead = new StreamReader(@txtFile.Text);
            string       szLine  = "";

            string[] szFields;
            string[] szHeader;
            szLine   = gperead.ReadLine();
            szLine   = szLine.Replace("\"", "");
            szHeader = szLine.Split(SEPARATOR);
            Teradata.Client.Provider.TdCommand gpeCmd = new Teradata.Client.Provider.TdCommand("SELECT * FROM " + cboDatabaseList.Text + "." + cboTables.Text, mainConn);
            gpeCmd.CommandTimeout = 10000;

            int counter = 0;

            Teradata.Client.Provider.TdDataAdapter gpeAdapter = new Teradata.Client.Provider.TdDataAdapter(gpeCmd);
            gpeAdapter.UpdateBatchSize = 100000;

            gpeAdapter.KeepCommandBatchSequence = false;
            Teradata.Client.Provider.TdCommandBuilder cb = new Teradata.Client.Provider.TdCommandBuilder(gpeAdapter);
            DataTable dt = new DataTable();

            gpeAdapter.Fill(dt);

            while ((szLine = gperead.ReadLine()) != null)
            {
                szLine   = szLine.Replace("\"", "");
                szFields = szLine.Split(SEPARATOR);

                DataRow dr = dt.NewRow();

                if (szFields.GetUpperBound(0) == szHeader.GetUpperBound(0))
                {
                    for (int i = 0; i < szHeader.GetLength(0); i++)
                    {
                        if (szFields[i] == "?")
                        {
                            dr[szHeader[i]] = DBNull.Value;
                        }
                        else if (dr.Table.Columns[szHeader[i]].DataType == typeof(DateTime))
                        {
                            try {
                                dr[szHeader[i]] = Convert.ToDateTime(szFields[i].Trim('\"'));
                            }
                            catch (Exception ex) {
                                dr[szHeader[i]] = DBNull.Value;
                            }
                        }
                        else if (dr.Table.Columns[szHeader[i]].DataType == typeof(double))
                        {
                            dr[szHeader[i]] = Convert.ToDecimal(szFields[i].Trim('\"').Replace('.', ','));
                        }
                        else
                        {
                            try {
                                dr[szHeader[i]] = szFields[i].Trim('\"');
                            }
                            catch (Exception ex) {
                                dr[szHeader[i]] = DBNull.Value;
                            }
                        }
                    }

                    dt.Rows.Add(dr);
                }



                if ((counter++ % 100000) == 0)
                {
                    try {
                        gpeAdapter.Update(dt);
                    }
                    catch (Exception ex) {
                        MessageBox.Show(this, ex.Message);
                    }

                    textBox1.Text = (counter - 1).ToString();
                }

                Application.DoEvents();
            }

            gpeAdapter.Update(dt);
            textBox1.Text = counter.ToString();

            dt.Dispose();
            gpeCmd.Dispose();
            mainConn.Close();
            mainConn.Dispose();
            gperead.Close();
            sw.Stop();
            MessageBox.Show("Done!\n" + sw.Elapsed);
        }
        protected void ImageExport_Click(object sender, ImageClickEventArgs e)
        {
            string trteradataconnection = "Data Source='204.99.34.21';User ID='coebatch';Password='******';";

            Teradata.Client.Provider.TdConnection tereconnection = new Teradata.Client.Provider.TdConnection(trteradataconnection);
            //TdDataAdapter ID;
            // string defectid = TxtHistorySearch0.Text;

            // ID = dbObj.DefectHome();
            try
            {
                //  TdCommand Teracomd = new TdCommand("select * from coebatch.tbl_Defect", tereconnection);



                //TdDataAdapter AdvancedDefectSearch =
                //          new TdDataAdapter(@"Select DefectID,DefectName,Status,sDate,sCycle,Description,Project,Tester,TestcasesAssociated,Module,AssignedTo,Filenames,Filesize from  coebatch.tbl_Defect where  sDate between '" + fromdate + "' and '" + todate + "'", tereconnection);
                tereconnection.Open();
                TdDataAdapter AdvancedDefectSearch =
                    new TdDataAdapter(@"select Defectid,Defectname,sdate as OpenDate,Status,Scycle as Cycles,Project,Tester,Module,Assignedto,Closedate as LastUpdatedDate from coebatch.tbl_Defect order by Defectid asc ", tereconnection);

                // IDataSource dt1 = new IDataSource ;


                DataSet ds = new DataSet();

                AdvancedDefectSearch.Fill(ds);
                this.GridView1.DataSource = ds.Tables[0];
                GridView1.DataKeyNames    = new string[] { "Defectid" };
                this.GridView1.DataBind();
            }

            catch (Teradata.Client.Provider.TdException ex)
            {
                //Throw the exception to calling environment
                throw ex;
            }
            finally
            {
                //Close the Connection from the Database
                tereconnection.Close();;
            }

            string attachment = "attachment; filename=Export.xls";

            Response.ClearContent(); Response.AddHeader("content-disposition", attachment);
            Response.ContentType = "application/ms-excel";
            StringWriter   sw  = new StringWriter();
            HtmlTextWriter htw = new HtmlTextWriter(sw);

            // GridView1.HeaderRow.BackColor = Color.White;
            foreach (TableCell cell in GridView1.HeaderRow.Cells)
            {
                cell.BackColor = GridView1.HeaderStyle.BackColor;
                cell.Height    = 25;
            }


            foreach (GridViewRow row in GridView1.Rows)
            {
                foreach (TableCell cell in row.Cells)
                {
                    if (row.RowIndex % 1 == 0)
                    {
                        //cell.BackColor = GridView1.AlternatingRowStyle.BackColor;
                        cell.Height = 25;
                    }
                    else
                    {
                        cell.BackColor = GridView1.RowStyle.BackColor;
                    }
                    cell.CssClass = "textmode";
                }
            }

            GridView1.RenderControl(htw);
            Response.Write(sw.ToString());
            Response.End();

            //int columns = this.GridView1.Columns.Count;
            //    //GridView1.AllowPaging = false;
            //   // GridView1.DataBind();

            //    int Count = dbObj.GetDefectcount();
            //    Microsoft.Office.Interop.Excel.Application ExcelApp =
            // new Microsoft.Office.Interop.Excel.Application();
            //    Microsoft.Office.Interop.Excel._Workbook ExcelBook;
            //    Microsoft.Office.Interop.Excel._Worksheet ExcelSheet;

            //    int i = 0;
            //    int j = 0;

            //    //create object of excel
            //    ExcelBook = (Microsoft.Office.Interop.Excel._Workbook)ExcelApp.Workbooks.Add(1);
            //    ExcelSheet = (Microsoft.Office.Interop.Excel._Worksheet)ExcelBook.ActiveSheet;
            //    //export header

            //    for (i = 1; i <= this.GridView1.Columns.Count; i++)
            //    {
            //        ExcelSheet.Cells[1, i] = this.GridView1.Columns[i - 1].HeaderText;
            //    }

            //    //export data
            //    for (i = 1; i <= Count; i++)
            //    {
            //        for (j = 1; j <= GridView1.Columns.Count; j++)
            //        {
            //            ExcelSheet.Cells[i + 1, j] = GridView1.Rows[i - 1].Cells[j - 1].Text;
            //        }
            //    }

            //    ExcelApp.Visible = true;
            //    //GridView1.AllowPaging = true;
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["New"] == null)
            {
                Server.Transfer("Login2.aspx", true);

                // Response.Redirect("Login.aspx");
            }
            Page.Response.Cache.SetCacheability(HttpCacheability.NoCache);
            if (!this.IsPostBack)
            {
                if (Session["New"] == null)
                {
                    Server.Transfer("Login2.aspx", true);

                    // Response.Redirect("Login.aspx");
                }

                else
                {
                    Session["MySessionVar"] = 0;
                    int DefectID1 = (int)Session["MySessionVar"];

                    this.Master.Label = Session["New"].ToString();
                    LbMessage.Visible = false;
                    LbMessage.Text    = "";
                    //this.Session["DefectID11"] = DefectID1;
                    //Defect = this.Session["DefectID11"].ToString();
                    string trteradataconnection = "Data Source='204.99.34.21';User ID='coebatch';Password='******';";
                    Teradata.Client.Provider.TdConnection tereconnection = new Teradata.Client.Provider.TdConnection(trteradataconnection);
                    //TdDataAdapter ID;
                    // string defectid = TxtHistorySearch0.Text;

                    // ID = dbObj.DefectHome();
                    try
                    {
                        //  TdCommand Teracomd = new TdCommand("select * from coebatch.tbl_Defect", tereconnection);



                        //TdDataAdapter AdvancedDefectSearch =
                        //          new TdDataAdapter(@"Select DefectID,DefectName,Status,sDate,sCycle,Description,Project,Tester,TestcasesAssociated,Module,AssignedTo,Filenames,Filesize from  coebatch.tbl_Defect where  sDate between '" + fromdate + "' and '" + todate + "'", tereconnection);
                        tereconnection.Open();
                        TdDataAdapter AdvancedDefectSearch =
                            new TdDataAdapter(@"select Defectid,Defectname,sdate as OpenDate,Status,Scycle as Cycles,Project,Tester,Module,Assignedto,Closedate as LastUpdatedDate from coebatch.tbl_Defect order by Defectid asc ", tereconnection);

                        // IDataSource dt1 = new IDataSource ;

                        DataSet ds = new DataSet();


                        AdvancedDefectSearch.Fill(ds);
                        this.GridView1.DataSource = ds.Tables[0];
                        GridView1.DataKeyNames    = new string[] { "Defectid" };
                        this.GridView1.DataBind();
                    }

                    catch (Teradata.Client.Provider.TdException ex)
                    {
                        //Throw the exception to calling environment
                        throw ex;
                    }
                    finally
                    {
                        //Close the Connection from the Database
                        tereconnection.Close();;
                    }
                }
            }

            else
            {
            }
        }
        protected void BtnSearch_Click(object sender, EventArgs e)
        {
            DateTime Sysdate = DateTime.Now;

            fromdate = Calendarfrom.SelectedDate;
            todate   = CalendartoDate.SelectedDate;
            int defect = 0;

            if (fromdate > todate || fromdate > Sysdate || todate > Sysdate)
            {
                LbMessage.Visible = true;
                LbMessage.Text    = "Please enter the valid date range";
            }
            else
            {
                if

                (DDLAssignedto.SelectedValue == "" && DDLEnvironment.SelectedValue == "" &&
                 DDLModule.SelectedValue == "" && DDLProject.SelectedValue == "" && DDLProjectname.SelectedValue == "" &&
                 DDlStatus.SelectedValue == "" &&
                 DDLTester.SelectedValue == "" && txtfromdate.Text == "" && txtTodate.Text == "" && TxtDefectname.Text == "" && DDLCycle.SelectedValue == "")
                {
                    LbMessage.Visible = true;
                    LbMessage.Text    = "Please select any of the search items";
                }
                else
                {
                    try
                    {
                        string trteradataconnection = "Data Source='204.99.34.21';User ID='coebatch';Password='******';";
                        if (txtfromdate.Text != "" && txtTodate.Text != "")
                        {
                            Datefrom = Convert.ToDateTime(txtfromdate.Text);

                            DateTo    = Convert.ToDateTime(txtTodate.Text);
                            Datefrom1 = new TdTimestamp(Datefrom);
                            DateTo1   = new TdTimestamp(DateTo);
                        }
                        else
                        {
                            DateTime timetora = DateTime.Now;
                            string   text     = timetora.ToString("MM/dd/yyyy HH:mm:ss");
                            DateTime Test1    = Convert.ToDateTime(text);


                            DateTo1 = new TdTimestamp(Test1);
                        }

                        Teradata.Client.Provider.TdConnection tereconnection = new Teradata.Client.Provider.TdConnection(trteradataconnection);

                        //TdCommand Teracomd = new TdCommand("select * from coebatch.tbl_Defect", tereconnection);
                        //TdDataAdapter AdvancedDefectSearch =
                        //          new TdDataAdapter(@"Select DefectID,DefectName,Status,sDate,sCycle,Description,Project,Tester,TestcasesAssociated,Module,AssignedTo,Filenames,Filesize from  coebatch.tbl_Defect where  sDate between '" + fromdate + "' and '" + todate + "'", tereconnection);
                        TdCommand cmd = new TdCommand("COEBATCH.ADVANCEDDEFECTSEARCH1", tereconnection);

                        cmd.CommandType = CommandType.StoredProcedure;

                        cmd.Parameters.Add("VDefectname", TdType.VarChar).Value  = TxtDefectname.Text;
                        cmd.Parameters.Add("VStatus", TdType.VarChar).Value      = DDlStatus.SelectedValue;
                        cmd.Parameters.Add("VAssignedto", TdType.VarChar).Value  = DDLAssignedto.SelectedValue;
                        cmd.Parameters.Add("VTester", TdType.VarChar).Value      = DDLTester.SelectedValue;
                        cmd.Parameters.Add("VOpendate", TdType.Timestamp).Value  = Datefrom1;
                        cmd.Parameters.Add("VOpendate1", TdType.Timestamp).Value = DateTo1;
                        cmd.Parameters.Add("VProject", TdType.VarChar).Value     = DDLProject.SelectedValue;
                        cmd.Parameters.Add("VModule", TdType.VarChar).Value      = DDLModule.SelectedValue;
                        cmd.Parameters.Add("VEnvironment", TdType.VarChar).Value = DDLEnvironment.SelectedValue;
                        cmd.Parameters.Add("VRelease", TdType.VarChar).Value     = DDLProjectname.SelectedValue;
                        cmd.Parameters.Add("VCycle", TdType.VarChar).Value       = DDLCycle.SelectedValue;
                        //cmd.Parameters.Add("cur1", TdType.AnyType).Direction =  ParameterDirection.Output;


                        tereconnection.Open();



                        DataTable dt = new DataTable();


                        dt.Load(cmd.ExecuteReader());


                        // defect = cmd.ExecuteNonQuery();

                        //    TdDataAdapter AdvancedDefectSearch =
                        //             new TdDataAdapter();
                        //AdvancedDefectSearch= new TdDataAdapter(cmd);

                        //// IDataSource dt1 = new IDataSource ;
                        //tereconnection.Open();


                        //DataSet ds = new DataSet();

                        //AdvancedDefectSearch.Fill(ds);
                        GridAdvancedSearch.DataSource = dt;
                        GridAdvancedSearch.DataBind();
                        //this.GridAdvancedSearch.DataSource = ds.Tables[0].DataSet;
                        //GridAdvancedSearch.DataKeyNames = new string[] { "Defectid" };
                        //this.GridAdvancedSearch.DataBind();
                        //this.GridAdvancedSearch.Visible = true;
                        if (GridAdvancedSearch.Rows.Count > 0)
                        {
                            rowcount          = GridAdvancedSearch.Rows.Count;
                            BtnExport.Enabled = true;
                        }
                        else
                        {
                            BtnExport.Enabled = false;
                        }
                    }


                    catch (Teradata.Client.Provider.TdException ex)
                    {
                        //Throw the exception to calling environment
                        throw ex;
                    }
                    finally
                    {
                        //Close the Connection from the Database
                    }

                    //GridAdvancedSearch.DataSource = dt;
                    // AdvancedDefectSearch.Fill(dt);
                }
            }
        }
Beispiel #6
0
        protected void Page_Load(object sender, EventArgs e)
        {
            Page.Response.Cache.SetCacheability(HttpCacheability.NoCache);
            if (Session["New"] == null)
            {
                Server.Transfer("Login2.aspx", true);

                // Response.Redirect("Login.aspx");
            }
            else
            {
                int Defectiid = 0;
                this.Master.WelLogIn = "";
                this.Master.Label    = Session["New"].ToString();
                lbmessage.Visible    = false;
                lbmessage.Text       = "";
                Defectiid            = (int)Session["MySessionVar"];
                string trteradataconnection = "Data Source='204.99.34.21';User ID='coebatch';Password='******';";
                Teradata.Client.Provider.TdConnection tereconnection = new Teradata.Client.Provider.TdConnection(trteradataconnection);
                int ID;
                // string defectid = TxtHistorySearch0.Text;

                ID = dbObj.DefectIDSearch(Defectiid);
                try
                {
                    if (ID == 0)
                    {
                        lbmessage.Visible = true;
                        lbmessage.Text    = "Please enter a valid DefectID and Search";
                    }

                    else
                    {
                        //  TdCommand Teracomd = new TdCommand("select * from coebatch.tbl_Defect", tereconnection);



                        //TdDataAdapter AdvancedDefectSearch =
                        //          new TdDataAdapter(@"Select DefectID,DefectName,Status,sDate,sCycle,Description,Project,Tester,TestcasesAssociated,Module,AssignedTo,Filenames,Filesize from  coebatch.tbl_Defect where  sDate between '" + fromdate + "' and '" + todate + "'", tereconnection);
                        tereconnection.Open();
                        TdDataAdapter AdvancedDefectSearch =
                            new TdDataAdapter(@"select Defectid,Defectname,sdate as CreatedDate,Status,Scycle as Cycles,Project as Releases,Tester,Module,Assignedto,Closedate as LastUpdateddate,Defecthistid,Severity,Environment,Releases as Project,Rootcause, Loginuser from coebatch.tbl_Defect_history where defectid = " + Defectiid + " order by defecthistid asc ", tereconnection);

                        // IDataSource dt1 = new IDataSource ;


                        DataSet ds = new DataSet();

                        AdvancedDefectSearch.Fill(ds);
                        this.GridHistory.DataSource = ds.Tables[0];
                        GridHistory.DataKeyNames    = new string[] { "Defecthistid" };
                        this.GridHistory.DataBind();
                    }
                }

                catch (Teradata.Client.Provider.TdException ex)
                {
                    //Throw the exception to calling environment
                    throw ex;
                }
                finally
                {
                    //Close the Connection from the Database
                    tereconnection.Close();;
                }
            }
        }