コード例 #1
0
        public ActionResult DeveloperResolve(DataView1 m)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    DatabaseClass  ctx = new DatabaseClass();
                    CommentDetails c   = new CommentDetails();
                    int            bid = int.Parse(Session["BugId"].ToString());
                    var            res = (from i in ctx.BugPoolDetail where i.BugId == bid select i).FirstOrDefault();
                    res.Status = "RESOLVED";

                    int uid = int.Parse(Session["UserId"].ToString());
                    c.CommentedBy = uid;
                    c.Comments    = m.dc;
                    c.BugId       = bid;
                    c.CommentDate = DateTime.Now;
                    ctx.CommentDetail.Add(c);

                    ctx.SaveChanges();
                    return(RedirectToAction("Developer", "Main"));
                }
                return(View(m));
            }
            catch
            {
                return(RedirectToAction("Error", "Main"));
            }
        }
コード例 #2
0
ファイル: Form1.cs プロジェクト: Gwinblade1/repository_git
        private void Button1_Click(object sender, EventArgs e)
        {
            SqlConnection con = new SqlConnection(ConnectionString);

            con.Open();

            SqlCommand comRead1 = new SqlCommand("SELECT * FROM Operators", con);

            SqlDataReader DR = comRead1.ExecuteReader();

            DataTable Op = new DataTable();

            Op.Load(DR);

            DataView1.DataSource = Op;
            DataView1.Refresh();

            con.Close();
        }
コード例 #3
0
ファイル: Form1.cs プロジェクト: Gwinblade1/repository_git
        private void Button2_Click(object sender, EventArgs e)
        {
            SqlConnection con = new SqlConnection(ConnectionString);

            con.Open();

            SqlCommand comRead2 = new SqlCommand("SELECT * FROM Hotlines", con);

            SqlDataReader DR = comRead2.ExecuteReader();

            DataTable Hl = new DataTable();

            Hl.Load(DR);

            DataView1.DataSource = Hl;
            DataView1.Refresh();

            con.Close();
        }
コード例 #4
0
        static void Demo()
        {
            using (var dt = new DataTable())
            {
                // DataTable.AddRange(DataColumn[]) is faster than DataTable.Add(string, Type) even though the former calls "new DataColumn" for each column.
                dt.Columns.AddRange(new[] { new DataColumn("FirstName", typeof(string)),
                                            new DataColumn("LastName", typeof(string)),
                                            new DataColumn("Age", typeof(int)) });

                //dt.Columns.Add("FirstName", typeof(string));
                //dt.Columns.Add("LastName", typeof(string));
                //dt.Columns.Add("Age", typeof(int));

                dt.Rows.Add("Dmitri", "Karamazov", 28);
                dt.Rows.Add("Ivan", "Karamazov", 24);
                dt.Rows.Add("Alexei", "Karamazov", 20);

                var          columns = new[] { "FirstName" };
                const string findMe  = "Ivan";
                var          dr1     = DataTable1.GetRow(dt, columns, findMe);
                Console.WriteLine("DataTable.Rows.Find() using ({0}) = ({1})", string.Join(", ", columns), string.Join(", ", findMe));
                Console.WriteLine("=> {0} {1} is found: Age = {2}\n", dr1["FirstName"], dr1["LastName"], dr1["Age"]);

                columns = new[] { "FirstName", "LastName" };
                var findObjects = new object[] { "Ivan", "Karamazov" };
                dr1 = DataTable1.GetRow(dt, columns, findObjects);
                Console.WriteLine("DataTable.Rows.Find() using ({0}) = ({1})", string.Join(", ", columns), string.Join(", ", findObjects));
                Console.WriteLine("=> {0} {1} is found: Age = {2}\n", dr1["FirstName"], dr1["LastName"], dr1["Age"]);

                Console.WriteLine("DataTable.Rows.Contains() using ({0}) = ({1})", string.Join(", ", columns), string.Join(", ", findObjects));
                Console.WriteLine("=> {0} {1} exists?: {2}\n", dr1["FirstName"], dr1["LastName"], dt.Rows.Contains(findObjects));

                Console.WriteLine("DataTable.Select() without filter");
                foreach (var dr in DataTable1.GetRows(dt))
                {
                    Console.WriteLine("=> {0} {1} is found: Age = {2}", dr["FirstName"], dr["LastName"], dr["Age"]);
                }
                Console.WriteLine();

                const string filter = "20 < Age";

                Console.WriteLine("DataTable.Select() using filter ({0})", filter);
                foreach (var dr in DataTable1.GetRows(dt, filter))
                {
                    Console.WriteLine("=> {0} {1} is found: Age = {2}", dr["FirstName"], dr["LastName"], dr["Age"]);
                }
                Console.WriteLine();

                const string sort = "Age DESC";
                Console.WriteLine("DataTable.Select() using filter ({0}) then sort ({1})", filter, sort);
                foreach (var dr in DataTable1.GetRows(dt, filter, sort))
                {
                    Console.WriteLine("=> {0} {1} is found: Age = {2}", dr["FirstName"], dr["LastName"], dr["Age"]);
                }
                Console.WriteLine();

                var dv = dt.DefaultView;

                var column  = "Age";
                var findInt = 20;
                var drv1    = DataView1.GetRow(dv, column, findInt);
                Console.WriteLine("DataView.Find() using {0} = {1}", column, findInt);
                Console.WriteLine("=> {0} {1} is found: Age = {2}\n", drv1["FirstName"], drv1["LastName"], drv1["Age"]);

                column      = "Age, LastName";
                findObjects = new object[] { "20", "Karamazov" };
                drv1        = DataView1.GetRow(dv, column, findObjects);
                Console.WriteLine("DataView.Find() using ({0}) = ({1})", column, string.Join(", ", findObjects));
                Console.WriteLine("=> {0} {1} is found: Age = {2}\n", drv1["FirstName"], drv1["LastName"], drv1["Age"]);

                column  = "Age";
                findInt = 20;
                Console.WriteLine("DataView.FindRows() using {0} = {1}", column, findInt);
                foreach (var drv in DataView1.GetRows(dv, column, findInt))
                {
                    Console.WriteLine("=> {0} {1} is found: Age = {2}", drv["FirstName"], drv["LastName"], drv["Age"]);
                }
                Console.WriteLine();

                column      = "Age, LastName";
                findObjects = new object[] { "20", "Karamazov" };
                Console.WriteLine("DataView.FindRows() using ({0}) = ({1})", column, string.Join(", ", findObjects));
                foreach (var drv in DataView1.GetRows(dv, column, findObjects))
                {
                    Console.WriteLine("=> {0} {1} is found: Age = {2}", drv["FirstName"], drv["LastName"], drv["Age"]);
                }
                Console.WriteLine();

                dv.RowFilter = filter;

                Console.WriteLine("DataView.RowFilter() using filter ({0})", filter);
                foreach (DataRowView drv in dv)
                {
                    Console.WriteLine("=> {0} {1} is found: Age = {2}", drv["FirstName"], drv["LastName"], drv["Age"]);
                }
                Console.WriteLine();

                dv.RowFilter = "";

                Console.WriteLine("DataView.RowFilter() without filter");
                foreach (DataRowView drv in dv)
                {
                    Console.WriteLine("=> {0} {1} is found: Age = {2}", drv["FirstName"], drv["LastName"], drv["Age"]);
                }
                Console.WriteLine();

                DataTable1.SetValue(dt, 2, "50");
                Console.WriteLine("DataTable.Columns[ColumnIndex].Expression = Value");
                foreach (var dr in DataTable1.GetRows(dt))
                {
                    Console.WriteLine("{0} {1} is Age {2}", dr["FirstName"], dr["LastName"], dr["Age"]);
                }
                Console.WriteLine();

                DataTable1.SetValue(dt, "Age", "100");
                Console.WriteLine("DataTable.Columns[ColumnName].Expression = Value");
                foreach (var dr in DataTable1.GetRows(dt))
                {
                    Console.WriteLine("{0}, {1} is Age {2}", dr["FirstName"], dr["LastName"], dr["Age"]);
                }
            }
        }
コード例 #5
0
 // Hides other views and show DataView1.
 public void ShowOnlyDataView1()
 {
     DataView2.Hide();
     DataView3.Hide();
     DataView1.Show();
 }