Exemplo n.º 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;
            }
        }
Exemplo n.º 2
0
        protected void GridViewResult_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            GridViewRow currentRow = e.Row;

            //if (currentRow.RowIndex > 0)
            if (currentRow.RowType == DataControlRowType.DataRow)
            {
                EmployeeToll employeeToll = (EmployeeToll)currentRow.DataItem;

                if (employeeToll.Attachment.Length == 0)
                {
                    currentRow.Cells[6].ForeColor = System.Drawing.Color.White;
                    currentRow.Cells[6].Text      = "-";
                    currentRow.Cells[6].Enabled   = false;
                }
            }
        }
Exemplo n.º 3
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;
            }
        }
Exemplo n.º 4
0
        protected void ButtonSave_Click(object sender, EventArgs e)
        {
            if (Page.IsValid)
            {
                LabelError.Text    = "";
                PanelError.Visible = false;

                DateTime dateOfToll;
                bool     isDate = DateTime.TryParse(TextBoxDateOfToll.Text, out dateOfToll);

                if (!isDate)
                {
                    LabelError.Text   += "Date Of Toll is required.<br />";
                    PanelError.Visible = true;
                    return;
                }

                //EmployeeToll currentEmployeeToll = EmployeeToll.GetEmployeeTollByVehicleIdEmployeeId(Convert.ToInt32(DropDownListVehicle.SelectedValue), this.employeeId);

                //EmployeeVehicle employeeVehicle = new EmployeeVehicle();
                //employeeVehicle.EmployeeVehicleId = currentEmployeeToll.EmployeeVehicleId;//Convert.ToInt32(ViewState["employeeVehicleId"]);
                //employeeVehicle.EmployeeId = this.employeeId;
                //employeeVehicle.VehicleId = Convert.ToInt32(DropDownListVehicle.SelectedValue);
                //employeeVehicle.ModifiedUser = this.Master.LoggedOnAccount;
                //employeeVehicle.Save();
                //ViewState["employeeVehicleId"] = (employeeVehicle.EmployeeVehicleId != 0) ? employeeVehicle.EmployeeVehicleId : this.employeeVehicleId;

                EmployeeVehicle employeeVehicle = EmployeeVehicle.GetEmployeeVehicleByEmployeeIdVehicleId(this.employeeId, Convert.ToInt32(DropDownListVehicle.SelectedValue));

                EmployeeToll employeeToll = new EmployeeToll();
                employeeToll.EmployeeTollId    = this.employeeTollId;//Convert.ToInt32(ViewState["employeeTollId"]);
                employeeToll.EmployeeVehicleId = employeeVehicle.EmployeeVehicleId;
                employeeToll.DateOfToll        = Convert.ToDateTime(TextBoxDateOfToll.Text);
                employeeToll.PaymentTypeId     = Convert.ToInt32(DropDownListPaymentType.SelectedValue);
                employeeToll.Value             = Convert.ToDouble(TextBoxValue.Text);
                employeeToll.Description       = TextBoxDescription.Text;
                employeeToll.ModifiedUser      = this.Master.LoggedOnAccount;
                employeeToll.Attachment        = UploadAttachment();

                try
                {
                    employeeToll.Save();
                    this.employeeTollId = employeeToll.EmployeeTollId;

                    Button clickedButton = (Button)sender;
                    switch (clickedButton.ID)
                    {
                    case "ButtonSave":
                        Response.Redirect(String.Format("EmployeeEdit.aspx?employeeId={0}", this.employeeId));
                        break;

                    case "ButtonSaveNew":
                        Response.Redirect(String.Format("EmployeeTollEdit.aspx?employeeId={0}&vehicleId={1}", this.employeeId, Convert.ToInt32(DropDownListVehicle.SelectedValue)));
                        //TextBoxValue.Text = "";
                        //TextBoxDescription.Text = "";
                        //TextBoxKMReading.Text = "";
                        //ViewState["employeeTollId"] = "0";
                        //ViewState["employeeVehicleId"] = "0";
                        //BindGridviewResult();
                        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;
                }
            }
        }
Exemplo n.º 5
0
 private void BindGridviewResult()
 {
     GridViewResult.DataSource = EmployeeToll.GetEmployeeTollList(this.employeeId);
     GridViewResult.DataBind();
 }