protected void btnUpdate_Click(object sender, EventArgs e) { try { if (CnfResult.Value == "true") { if (dtpFromTime.SelectedTime.ToString() == "") { ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "alert", "alert('Please Select Time');", true); return; } DateTime cdate = DateTime.Today; DateTime tdate = Convert.ToDateTime(TillDate.SelectedDate); string strstatus = ddlupstatus.SelectedValue; string filename = Path.GetFileName(FileUpd.FileName); String File; string strfile = ""; if (!FileUpd.HasFile) { File = TxtImge.Text; } else { strfile = DateTime.Now.ToString("ddmmyyhhmmsss") + "_" + filename; File = (@"~//EventImages/") + strfile.ToString(); FileUpd.SaveAs(Server.MapPath(@"~//EventImages/") + strfile.ToString()); } string rsn = Session["RSN"].ToString(); sqlobj.ExecuteNonQuery("Proc_Events", new SqlParameter() { ParameterName = "@i", SqlDbType = SqlDbType.Int, Value = 3 }, new SqlParameter() { ParameterName = "@Fromdate", SqlDbType = SqlDbType.DateTime, Value = FromDate.SelectedDate.Value }, new SqlParameter() { ParameterName = "@Tilldate", SqlDbType = SqlDbType.DateTime, Value = TillDate.SelectedDate.Value }, new SqlParameter() { ParameterName = "@FromTime", SqlDbType = SqlDbType.NVarChar, Value = dtpFromTime.SelectedTime.ToString() }, new SqlParameter() { ParameterName = "@EventName", SqlDbType = SqlDbType.NVarChar, Value = txtEventName.Text }, new SqlParameter() { ParameterName = "@Description", SqlDbType = SqlDbType.NVarChar, Value = txtdesc.Text }, new SqlParameter() { ParameterName = "@EventType", SqlDbType = SqlDbType.NVarChar, Value = "E" }, new SqlParameter() { ParameterName = "@Status", SqlDbType = SqlDbType.NVarChar, Value = ddlupstatus.SelectedValue }, new SqlParameter() { ParameterName = "@IsSentMail", SqlDbType = SqlDbType.NVarChar, Value = chkIsSentMail.Checked.ToString() }, new SqlParameter() { ParameterName = "@Images", SqlDbType = SqlDbType.NVarChar, Value = File }, new SqlParameter() { ParameterName = "@Remarks", SqlDbType = SqlDbType.NVarChar, Value = "" }, new SqlParameter() { ParameterName = "@RSN", SqlDbType = SqlDbType.NVarChar, Value = Session["RSN"].ToString() } ); LoadGrid(); clear(); WebMsgBox.Show("Event details updated successfully"); } } catch (Exception ex) { ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "alert", "alert('" + ex.Message.ToString() + "');", true); } }
protected void btnAddEvent_Click(object sender, EventArgs e) { try { if (CnfResult.Value == "true") { if (dtpFromTime.SelectedTime.ToString() == "") { ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "alert", "alert('Please Select Time');", true); return; } string filename = string.Empty; String File = ""; if (FileUpd.HasFile) { if (FileUpd.PostedFile.FileName.Length > 0) { filename = Path.GetFileName(FileUpd.PostedFile.FileName); FileUpd.SaveAs(Server.MapPath(@"~//EventImages/") + DateTime.Now.ToString("ddmmyyhhmmsss") + "_" + filename); File = (@"~//EventImages/") + DateTime.Now.ToString("ddmmyyhhmmsss") + "_" + filename; } else { File = ""; } } sqlobj.ExecuteNonQuery("Proc_Events", new SqlParameter() { ParameterName = "@i", SqlDbType = SqlDbType.Int, Value = 2 }, new SqlParameter() { ParameterName = "@Fromdate", SqlDbType = SqlDbType.DateTime, Value = FromDate.SelectedDate.Value }, new SqlParameter() { ParameterName = "@Tilldate", SqlDbType = SqlDbType.DateTime, Value = FromDate.SelectedDate.Value }, new SqlParameter() { ParameterName = "@FromTime", SqlDbType = SqlDbType.NVarChar, Value = dtpFromTime.SelectedTime.ToString() }, new SqlParameter() { ParameterName = "@EventName", SqlDbType = SqlDbType.NVarChar, Value = txtEventName.Text }, new SqlParameter() { ParameterName = "@Description", SqlDbType = SqlDbType.NVarChar, Value = txtdesc.Text }, new SqlParameter() { ParameterName = "@EventType", SqlDbType = SqlDbType.NVarChar, Value = "E" }, new SqlParameter() { ParameterName = "@Status", SqlDbType = SqlDbType.NVarChar, Value = "00" }, new SqlParameter() { ParameterName = "@IsSentMail", SqlDbType = SqlDbType.NVarChar, Value = chkIsSentMail.Checked.ToString() }, new SqlParameter() { ParameterName = "@Images", SqlDbType = SqlDbType.NVarChar, Value = File } ); DateTime fdate = Convert.ToDateTime(FromDate.SelectedDate.Value); DateTime tdate = Convert.ToDateTime(FromDate.SelectedDate.Value); if (chkIsSentMail.Checked == true) { EventMail(txtEventName.Text, txtdesc.Text, fdate, tdate); } LoadGrid(); clear(); WebMsgBox.Show("Event added."); } } catch (Exception ex) { WebMsgBox.Show(ex.Message); } }