예제 #1
0
        private void BindEmployeeToll()
        {
            try
            {
                EmployeeToll employeeToll = EmployeeToll.GetEmployeeTollByEmployeeTollId(this.employeeTollId);
                DropDownListVehicle.Items.FindByValue(employeeToll.VehicleId.ToString()).Selected = true;
                TextBoxDateOfToll.Text = employeeToll.DateOfToll.ToString("yyyy/MM/dd");
                DropDownListPaymentType.Items.FindByValue(employeeToll.PaymentTypeId.ToString()).Selected = true;
                TextBoxValue.Text       = employeeToll.Value.ToString();
                TextBoxDescription.Text = employeeToll.Description.ToString();

                BindGridviewResult();
            }
            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;
            }
        }
예제 #2
0
        protected void GridViewResult_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            try
            {
                switch (e.CommandName.ToLower())
                {
                case "removeemployeetoll":
                {
                    EmployeeToll.DeleteEmployeeTollByEmployeeTollId(Convert.ToInt32(e.CommandArgument));
                    BindGridviewResult();
                    break;
                }

                case "viewattachment":
                {
                    EmployeeToll employeeToll = EmployeeToll.GetEmployeeTollByEmployeeTollId(Convert.ToInt32(e.CommandArgument));

                    Response.Clear();
                    Response.ContentType = "image/jpg";
                    Response.AppendHeader("Content-Disposition", "attachment; filename=TollAttachment.jpg");
                    Response.TransmitFile(employeeToll.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;
            }
        }