Athmuri Murali
Сэр,
Пожалуйста, проверьте мой код. Пожалуйста, оформите заказ по адресу " tc.Text = dt.Rows[hj].Метод toString();";
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
public partial class Edittime : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
DataTable dt1 = new DataTable();
timetbal obj = new timetbal();
if (!IsPostBack)
{
dt1 = obj.class1();
for (int i = 0; i < dt1.Rows.Count; i++)
{
DataRow dr = dt1.Rows[i];
DropDownList1.Items.Add(dr[0].ToString());
}
}
}
string clas;
string sec;
ArrayList jk = new ArrayList();
string f = "murali";
string tim1;
DataTable dk = new DataTable();
BoundField bField = new BoundField();
BoundField bField1 = new BoundField();
BoundField bField2 = new BoundField();
BoundField bField3 = new BoundField();
static TimeSpan t3;
static TimeSpan t4;
static TimeSpan n6;
static TimeSpan n8;
string k1;
protected void Button1_Click(object sender, EventArgs e)
{
timetbal tbal = new timetbal();
DataTable dt = new DataTable();
string class1 = DropDownList1.SelectedItem.ToString();
string[] k = class1.Split('-');
clas = k[0].ToString();
sec = k[1].ToString();
dt = tbal.retrivevalues(clas, sec);
string start_time = dt.Rows[0][0].ToString();
string period_time = dt.Rows[0][1].ToString();
string no_period = dt.Rows[0][2].ToString();
string break_time = dt.Rows[0][3].ToString();
string lunch_time = dt.Rows[0][4].ToString();
//Header Text Values
GridView2.Width = 1500;
int n = Convert.ToInt32(no_period);
for (int i = 0; i < n; i++)
{
if (i == 0)
{
TimeSpan t1 = System.TimeSpan.Parse(start_time);
TimeSpan t2 = System.TimeSpan.Parse(period_time);
t3 = t1.Add(t2);
string h = Convert.ToString(t1) + "-" + Convert.ToString(t3);
GridView2.Visible = true;
bField.HeaderText = h.ToString();
GridView2.Columns.Add(bField);
}
else if (i < 2)
{
TimeSpan t1 = t3;
TimeSpan t2 = System.TimeSpan.Parse(period_time);
t3 = t1.Add(t2);
Label6.Text = Convert.ToString(t1) + "-" + Convert.ToString(t3);
GridView2.Visible = true;
BoundField bField = new BoundField();
bField.HeaderText = Label6.Text;
GridView2.Columns.Add(bField);
}
else if (i == 2)
{
TimeSpan n1 = System.TimeSpan.Parse(break_time);
t4 = t3.Add(n1);
string k1 = Convert.ToString(t3) + "-" + Convert.ToString(t4);
Label lbl = new Label();
lbl.Text = k1.ToString();
bField1.HeaderText = lbl.Text;
GridView2.Columns.Add(bField1);
}
else if (i > 2 && i < 5)
{
TimeSpan t1 = t4;
TimeSpan t2 = System.TimeSpan.Parse(period_time);
t4 = t1.Add(t2);
Label6.Text = Convert.ToString(t1) + "-" + Convert.ToString(t4);
GridView2.Visible = true;
BoundField bField = new BoundField();
bField.HeaderText = Label6.Text;
GridView2.Columns.Add(bField);
}
else if (i == 5)
{
TimeSpan n5 = System.TimeSpan.Parse(lunch_time);
n6 = t4.Add(n5);
string f = Convert.ToString(t4) + "-" + Convert.ToString(n6);
Label lbl1 = new Label();
lbl1.Text = f.ToString();
bField2.HeaderText = lbl1.Text;
GridView2.Columns.Add(bField2);
}
else if (i > 5 && i < 8)
{
TimeSpan t1 = n6;
TimeSpan t2 = System.TimeSpan.Parse(period_time);
n6 = t1.Add(t2);
Label6.Text = Convert.ToString(t1) + "-" + Convert.ToString(n6);
GridView2.Visible = true;
BoundField bField = new BoundField();
bField.HeaderText = Label6.Text;
GridView2.Columns.Add(bField);
}
else if (i == 8)
{
TimeSpan n7 = System.TimeSpan.Parse(break_time);
n8 = n6.Add(n7);
string q = Convert.ToString(n6) + "-" + Convert.ToString(n8);
bField3.HeaderText = q.ToString();
GridView2.Columns.Add(bField3);
}
else
{
TimeSpan t11 = n8;
TimeSpan t2 = System.TimeSpan.Parse(period_time);
n8 = t11.Add(t2);
string aa = Convert.ToString(t11) + "-" + Convert.ToString(n8);
GridView2.Visible = true;
BoundField bField = new BoundField();
bField.HeaderText = aa.ToString();
GridView2.Columns.Add(bField);
}
}
GridView2.DataBind();
for (int j = 1; j < GridView2.Columns.Count; j++)
{
tim1 = GridView2.Columns[j].HeaderText;
dt = tbal.retriveheader(clas, sec, tim1);
GridView2.DataSource = dt;
GridView2.DataBind();
k1 = dt.Rows[0][1].ToString();
//dk = tbal.retriveheaderdata(clas, sec, k1, tim1);
//for (int hj = 0; hj < dk.Rows.Count; hj++)
//{
// DataRow dr = dk.Rows[hj];
// dk.Rows.Add(dr[0].ToString());
// //GridView2.DataSource = dk;
// // GridView2.DataBind();
//}
dk = tbal.retriveheaderdata(clas, sec, k1, tim1);
for (int hj = 0; hj < dk.Rows.Count; hj++)
{
TableCell tc = new TableCell();
Label ll = new Label();
ll.ID = f + hj.ToString();
tc.Controls.Add(ll);
tc.Text = dt.Rows[hj].ToString();
GridView2.Rows[hj].Cells.Add(tc);
}
}
}
}