Beispiel #1
0
 public void BindEmployeeLeaveDays()
 {
     try
     {
         EmployeeLeaveDays employeeLeaveDays = EmployeeLeaveDays.GetEmployeeLeaveDaysByEmployeeLeaveDaysId(this.employeeLeaveDaysId);
         ViewState["employeeLeaveId"] = employeeLeaveDays.EmployeeLeaveId;
         DropDownListLeaveType.Items.FindByValue(employeeLeaveDays.LeaveTypeId.ToString()).Selected = true;
         TextBoxStartDate.Text = employeeLeaveDays.StartDate.ToString("yyyy/MM/dd");
         TextBoxEndDate.Text   = employeeLeaveDays.EndDate.ToString("yyyy/MM/dd");
         TextBoxDays.Text      = employeeLeaveDays.Days.ToString();
         TextBoxComment.Text   = employeeLeaveDays.Comment;
     }
     catch (System.Data.SqlClient.SqlException sqlEx)
     {
         for (int i = 0; i < sqlEx.Errors.Count; i++)
         {
             LabelError.Text += (sqlEx.Errors[i].Message + "<br />");
         }
         PanelError.Visible = true;
     }
     catch (Exception exception)
     {
         LabelError.Text   += (exception.Message + "<br />");
         PanelError.Visible = true;
     }
 }
Beispiel #2
0
        protected void GridViewResult_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            try
            {
                switch (e.CommandName.ToLower())
                {
                case "deleteleave":
                {
                    EmployeeLeaveDays.DeleteEmployeeLeaveDaysByEmployeeLeaveDaysId(Convert.ToInt32(e.CommandArgument), this.Master.LoggedOnAccount);
                    EmployeeLeave.UpdateEmloyeeLeaveCurrentDaysByEmployeeLeaveDaysId(Convert.ToInt32(e.CommandArgument), 2 /*Delete*/, this.Master.LoggedOnAccount);

                    SendEmployeeLeaveDeletionNotificationList();

                    BindGridviewResult();
                    BindEmployeeLeave();

                    break;
                }

                case "viewattachment":
                {
                    EmployeeLeaveDays employeeLeaveDays = EmployeeLeaveDays.GetEmployeeLeaveDaysByEmployeeLeaveDaysId(Convert.ToInt32(e.CommandArgument));
                    //Response.Redirect(String.Format("{0}",employeeLeaveDays.Attachment));

                    //System.IO.FileStream fs = null;
                    //fs = System.IO.File.Open(employeeLeaveDays.Attachment, System.IO.FileMode.Open);
                    //byte[] btFile = new byte[fs.Length];
                    //fs.Read(btFile, 0, Convert.ToInt32(fs.Length));
                    //fs.Close();
                    //Response.AddHeader("Content-disposition", "attachment; filename=" + "LeaveAttachment");
                    //Response.ContentType = "image/jpeg";
                    //Response.BinaryWrite(btFile);
                    //Response.End();

                    Response.Clear();
                    Response.ContentType = "image/jpg";
                    Response.AppendHeader("Content-Disposition", "attachment; filename=LeaveAttachment.jpg");
                    Response.TransmitFile(employeeLeaveDays.Attachment);
                    Response.End();

                    break;
                }
                }
            }
            catch (System.Data.SqlClient.SqlException sqlEx)
            {
                LabelError.Text = "";
                for (int i = 0; i < sqlEx.Errors.Count; i++)
                {
                    LabelError.Text += (sqlEx.Errors[i].Message + "<br />");
                }
                PanelError.Visible = true;
            }
        }
 private void BindEmployeeLeaveDays()
 {
     TextBoxReportsToComment.Text = EmployeeLeaveDays.GetEmployeeLeaveDaysByEmployeeLeaveDaysId(this.employeeLeaveDaysId).ReportsToComment;
 }