hello
when i try insert new data from second Panel. after insert it back me to panel 1
i want stay on second panel
button1(( Butt1out )) = first
buttton2 (( Butt2back )) = second
protected void Butt1out(object sender, EventArgs e)
{
vacationout.Visible = true;
vacationback.Visible = false;
}
protected void Butt2back(object sender, EventArgs e)
{
vacationout.Visible = false;
vacationback.Visible = true;
}
insert new data
protected void Insert2(object sender, EventArgs e)
{
string filename = Path.GetFileName(FileUpload2.PostedFile.FileName);
string contentType = FileUpload2.PostedFile.ContentType;
using (Stream fs = FileUpload2.PostedFile.InputStream)
{
using (BinaryReader br = new BinaryReader(fs))
{
byte[] bytes = br.ReadBytes((Int32)fs.Length);
string constr = ConfigurationManager.ConnectionStrings["kankonConnectionString"]
.ConnectionString;
using (SqlConnection con = new SqlConnection(constr))
{
string query = "insert into [Table_vacation] (idnamev ,jop ,eldarajah ,el3malv ,datesp10, idcivilv, datestart,dateend, dateorder, totalva, infovacation, namevacation,noteback,dateback,Name, ContentType, backupmyfile) VALUES (@idnamev ,@jop ,@eldarajah ,@el3malv ,@datesp10, @idcivilv, @datestart, @dateend, @dateorder, @totalva, @infovacation, @namevacation,@noteback,@dateback,@Name, @ContentType, @backupmyfile)";
using (SqlCommand cmd = new SqlCommand(query))
{
cmd.Connection = con;
cmd.Parameters.AddWithValue("@Name", filename);
cmd.Parameters.AddWithValue("@ContentType", contentType);
cmd.Parameters.AddWithValue("@backupmyfile", bytes);
cmd.Parameters.AddWithValue("@idnamev", txtUsername.Text); //الاسم
cmd.Parameters.AddWithValue("@jop", joptitel.Text); // الوظيفة
cmd.Parameters.AddWithValue("@eldarajah", eldarajah.Text); // الدرجة
cmd.Parameters.AddWithValue("@el3malv", markazel3mel.Text); // القسم
cmd.Parameters.AddWithValue("@datesp10", filenumber.Text); // رقم الملف
cmd.Parameters.AddWithValue("@idcivilv", civilid.Text); // رقك المدمي
cmd.Parameters.AddWithValue("@datestart", txtBoxDate8.Text); // ناريح بداية الاجازة
cmd.Parameters.AddWithValue("@dateend", txtBoxDate10.Text); // نهاية الاجازة
cmd.Parameters.AddWithValue("@dateorder", txtBoxDate7.Text); //تاريخ الطلب
cmd.Parameters.AddWithValue("@totalva", lblLabel2.Text); // عدد ايام الاجازه
cmd.Parameters.AddWithValue("@infovacation", VacationList2.Text); // نوع الاجازه
cmd.Parameters.AddWithValue("@namevacation", "اقرار عودة"); // اسم الاجازة
cmd.Parameters.AddWithValue("@noteback", textmsg.Text); // ملاحظات الاقرار العوده
cmd.Parameters.AddWithValue("@dateback", txtBoxDate11.Text); // مباشرة العودة
cmd.Connection = con;
con.Open();
cmd.ExecuteNonQuery();
con.Close();
}
}
}
Response.Redirect(Request.Url.AbsoluteUri);
}
}
protected void Page_Load(object sender, EventArgs e)
{
if (!this.IsPostBack)
{
BindGridView();
}
cal_vaca();
}
private void BindGridView()
{
try
{
txtBoxDate.Text = DateTime.Now.ToString("yyyy/MM/dd");
txtBoxDate2.Text = DateTime.Now.ToString("yyyy/MM/dd");
txtBoxDate4.Text = DateTime.Now.ToString("yyyy/MM/dd");
txtBoxDate7.Text = DateTime.Now.ToString("yyyy/MM/dd");
txtBoxDate8.Text = DateTime.Now.ToString("yyyy/MM/dd");
txtBoxDate10.Text = DateTime.Now.ToString("yyyy/MM/dd");
txtBoxDate11.Text = DateTime.Now.ToString("yyyy/MM/dd");
using (SqlConnection con = new SqlConnection(str))
{
using (SqlDataAdapter da = new SqlDataAdapter("SELECT * FROM Table_vacation WHERE datestart >= DATEADD(MONTH, -3, GETDATE())", con))
{
using (DataTable dt = new DataTable())
{
da.Fill(dt);
gvFiles.DataSource = dt;
gvFiles.DataBind();
int totalhidebutton = Convert.ToInt32(gvFiles.FooterRow.Cells[9].Text);
if (totalhidebutton <= 0)
{
AddUsers.Enabled = false;
}
else if (totalhidebutton > 0 && totalhidebutton <= 76)
{
AddUsers.Enabled = true;
}
}
}
}
}
catch (Exception)
{
}
}