Esempio n. 1
0
        public int GetInToParkingTurnMode(TicketForTurnModeDto ticket)
        {
            using (SqlConnection connection = new SqlConnection(Config.ConnectionString))
            {
                try
                {
                    connection.Open();
                    SqlCommand cmd =
                        new SqlCommand("usp_get_in_turn_mode", connection)
                    {
                        CommandType = CommandType.StoredProcedure
                    };
                    cmd.Parameters.Add(new SqlParameter("@ticketId", ticket.ID));
                    cmd.Parameters.Add(new SqlParameter("@licsenPlate", ticket.LicensePlate));
                    cmd.Parameters.Add(new SqlParameter("@time", DateTime.Now));
                    cmd.Parameters.Add(new SqlParameter("@areaId", ticket.AreaID));
                    cmd.Parameters.Add(new SqlParameter("@vehicleType", ticket.VehicleType));
                    var returnParam = cmd.Parameters.Add("@result", SqlDbType.Int);
                    returnParam.Direction = ParameterDirection.ReturnValue;

                    cmd.ExecuteNonQuery();
                    int result = (int)returnParam.Value;

                    if (result != 0)
                    {
                        return(Constants.RESULT_OK);
                    }
                    return(Constants.RESULT_ERROR);
                }
                catch (Exception e)
                {
                    return(Constants.RESULT_ERROR);
                }
            }
        }
Esempio n. 2
0
        private void btnSubmit_Click(object sender, EventArgs e)
        {
            if (turnMode)
            {
                if (cbArea.SelectedIndex == -1 || cbType.SelectedIndex == -1 || tbTicketIdGen.Text.Equals(""))
                {
                    MessageBox.Show("Vui lòng nhâp đầy đủ thông tin!", "Thông báo", MessageBoxButtons.OK,
                                    MessageBoxIcon.Information);
                    return;
                }

                TicketForTurnModeDto ticket = new TicketForTurnModeDto()
                {
                    AreaID       = cbArea.SelectedIndex + 1,
                    ID           = tbTicketIdGen.Text,
                    LicensePlate = tbLicensePlate.Text,
                    VehicleType  = cbType.SelectedIndex + 1
                };
                int result = parkingDao.GetInToParkingTurnMode(ticket);

                if (result == Constants.RESULT_OK)
                {
                    btnRefresh_Click(null, null);
                }
                else
                {
                    MessageBox.Show("Có lỗi xảy ra!\nKhu vực đã hết chỗ!", "Lỗi", MessageBoxButtons.OK,
                                    MessageBoxIcon.Error);
                }
            }

            else
            {
                if (tbTicketIdInput.Text.Equals("") || tbCustomerName.Text.Equals(""))
                {
                    return;
                }

                if (btnExtendTerm.Visible)
                {
                    MessageBox.Show("Gia hạn trước khi vào bãi!", "Lỗi", MessageBoxButtons.OK,
                                    MessageBoxIcon.Error);
                    return;
                }
                else
                {
                    int result = parkingDao.GetInToParkingTermMode(tbTicketIdInput.Text.Trim());
                    if (result == Constants.RESULT_OK)
                    {
                        btnRefresh_Click(null, null);
                    }
                    else
                    {
                        MessageBox.Show("Có lỗi xảy ra!\nKhu vực đã hết chỗ!", "Lỗi", MessageBoxButtons.OK,
                                        MessageBoxIcon.Error);
                    }
                }
            }
        }