示例#1
0
        private void dvgAllAtmUsersEditing_SelectionChanged(object sender, EventArgs e)
        {
            DataGridView dgv = (DataGridView)sender;

            try
            {
                if (dgv.SelectedRows.Count > 0)
                {
                    string currentUserId = dgv.SelectedRows[0].Cells[0].Value.ToString();
                    userId = int.Parse(currentUserId);

                    AtmUserModel userData = this.userService.GetAtmUserData(userId);

                    txtAtmUserName.Text          = userData.Name.ToString();
                    txtAtmUserSurname.Text       = userData.Surname.ToString();
                    txtAtmUserContactNumber.Text = userData.ContactNumber.ToString();
                    txtAtmUserContactMail.Text   = userData.Email.ToString();
                    txtAtmUserBranch.Text        = userData.Branch.ToString();
                    txtAtmUserCompany.Text       = userData.Company.ToString();
                    txtAtmUserWorkPlace.Text     = userData.UserType.ToString();
                }
            }
            catch (Exception ex)
            {
                this.ShowErrorMessage(ex);
            }
        }
示例#2
0
        public List <AtmUserModel> GetAllUsers()
        {
            DataTable data = new DataTable();

            using (SqlConnection con = new SqlConnection(this.ConnectionString))
            {
                SqlCommand     cmd = new SqlCommand();
                SqlDataAdapter da  = new SqlDataAdapter();
                DataTable      dt  = new DataTable();

                //Create Technician List
                List <AtmUserModel> _users = new List <AtmUserModel>();

                try
                {
                    cmd = new SqlCommand("procGetAllAtmUsers", con);

                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Connection.Open();
                    da.SelectCommand = cmd;
                    da.Fill(dt);
                    cmd.Connection.Close();

                    foreach (DataRow row in dt.Rows)
                    {
                        AtmUserModel _user = new AtmUserModel();
                        _user.Id   = Convert.ToInt32(row["Atm_user_ID"]);
                        _user.Name = row["Name"].ToString();
                        _user.Name = row["Surname"].ToString();
                        _user.Name = row["Contact_number"].ToString();
                        _user.Name = row["Contact_email"].ToString();
                        _user.Name = row["Branch"].ToString();
                        _user.Name = row["Company"].ToString();
                        _user.Name = row["Atm_user_name"].ToString();
                        _user.Name = row["Atm_user_password"].ToString();
                        _user.Name = row["User_type"].ToString();


                        _users.Add(_user);
                    }
                }
                catch (Exception x)
                {
                    MessageBox.Show(x.GetBaseException().ToString(), "Error",
                                    MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                finally
                {
                    cmd.Dispose();
                    //pl.MySQLConn.Close();
                }
                return(_users);
            }
        }
示例#3
0
        private void btnSaveInterventions_Click(object sender, EventArgs e)
        {
            //MessageBox.Show(dateOfInter.ToShortDateString());
            AtmModel atm = new AtmModel();
            //TO DO Rješit USERA DA SE LOGIRA , Globalnu variablu stavit
            var          userid = 1;
            AtmUserModel user   = new AtmUserModel();

            user.Id = userid;
            //ako je punjenje

            foreach (DataGridViewRow item in dgvAddAtmToIntervention.Rows)
            {
                DataGridViewComboBoxCell cb = (DataGridViewComboBoxCell)item.Cells[4];


                if (cb.Value != null)
                {
                    atm.Id = Convert.ToInt32(item.Cells[5].Value);//id


                    switch (cb.Value.ToString())
                    {
                    case "Punjenje":
                        int a          = Convert.ToInt32(item.Cells[6].Value);
                        int b          = Convert.ToInt32(item.Cells[7].Value);
                        var flagRefill = this.orderService.AddRefillOrder(dateOfInter, atm, user, a, b);
                        break;

                    case "Greska":
                        var flagError = this.orderService.AddErrorOrder(dateOfInter, atm, user);
                        break;

                    case "Kvar":
                        var flagMal = this.orderService.AddMalfunctionOrder(dateOfInter, atm, user);
                        break;

                    case "Zadrzana kartica":
                        break;

                    default:
                        throw new ArgumentException("Nepoznata intervencija");
                    }
                }
                else
                {
                    MessageBox.Show("Odaberite intervenciju");
                }//end if
            }
        }
示例#4
0
        public bool AddAtmUser(AtmUserModel user)
        {
            using (SqlConnection con = new SqlConnection(this.ConnectionString))
            {
                SqlCommand     cmd          = new SqlCommand();
                SqlDataAdapter da           = new SqlDataAdapter();//maknit
                var            rowsAffected = 0;
                try
                {
                    //TO DO napravit storanu procc za update component
                    cmd = new SqlCommand("procAddAtmUser", con);
                    cmd.Parameters.Add(new SqlParameter("@Name", user.Name));
                    cmd.Parameters.Add(new SqlParameter("@Surname", user.Surname));
                    cmd.Parameters.Add(new SqlParameter("@Contact_number", user.ContactNumber));
                    cmd.Parameters.Add(new SqlParameter("@Contact_email", user.Email));
                    cmd.Parameters.Add(new SqlParameter("@Branch", user.Branch));
                    cmd.Parameters.Add(new SqlParameter("@Company", user.Company));
                    cmd.Parameters.Add(new SqlParameter("@Atm_user_name", user.UserName));
                    cmd.Parameters.Add(new SqlParameter("@Atm_user_password", user.UserPassword));
                    cmd.Parameters.Add(new SqlParameter("@User_type", user.UserType));



                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Connection.Open();
                    rowsAffected = cmd.ExecuteNonQuery();
                    cmd.Connection.Close();
                }
                catch (Exception x)
                {
                    MessageBox.Show(x.GetBaseException().ToString(), "Error",
                                    MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                finally
                {
                    cmd.Dispose();
                    //pl.MySQLConn.Close();
                }

                if (rowsAffected > 0)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
        }
示例#5
0
        private void BtnAddNewUser_Click(object sender, EventArgs e)
        {
            try
            {
                if (this.ValidateUpdate())
                {
                    AtmUserModel userModel = new AtmUserModel();


                    userModel.Name          = txtNewAtmUserName.Text.Trim();
                    userModel.Surname       = txtNewAtmUserSurname.Text.Trim();
                    userModel.ContactNumber = txtNewAtmUserContactNumber.Text.Trim();
                    userModel.Email         = txtNewAtmUserContactMail.Text.Trim();
                    userModel.Branch        = txtNewAtmUserBranch.Text.Trim();
                    userModel.Company       = txtNewAtmUserCompany.Text.Trim();
                    userModel.UserName      = txtNewAtmUserUsername.Text.Trim();
                    userModel.UserPassword  = txtNewAtmUserPassword.Text.Trim();
                    userModel.UserType      = txtNewAtmUserWorkplace.Text.Trim();

                    //Add new AtmUser and return bool
                    var flag = this.userService.AddAtmUser(userModel);

                    this.Close();

                    if (flag)
                    {
                        MessageBox.Show(
                            Resources.Update_Successful_Message,
                            Resources.Update_Successful_Message_Title,
                            MessageBoxButtons.OK,
                            MessageBoxIcon.Information);
                    }
                }
                else
                {
                    MessageBox.Show(
                        this.errorMessage,
                        Resources.Update_Error_Message_Title,
                        MessageBoxButtons.OK,
                        MessageBoxIcon.Error);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.GetBaseException().ToString(), "Error",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
                this.ShowErrorMessage(ex);
            }
        }
示例#6
0
        private void btnRegisterNewMalfunctionOrder_Click(object sender, EventArgs e)
        {
            //TO DO Rješit USERA DA SE LOGIRA , Globalnu variablu stavit
            //Login
            var          userid = 1;
            AtmUserModel user   = new AtmUserModel();

            user.Id = userid;
            DateTime date = new DateTime(2018, 1, 1);
            AtmModel atm  = this.atmService.GetAtmByOrderId(orderId);
            var      flag = this.orderService.AddMalfunctionOrder(date, atm, user);

            DataTable data = this.orderService.GetAllOrdersByDate(date);

            this.LoadDataGridView(data);
        }
示例#7
0
        public AtmUserModel GetAtmUserData(int userId)
        {
            DataTable data = new DataTable();
            //DataRow dataRow;
            AtmUserModel _atmUser = new AtmUserModel();

            using (SqlConnection con = new SqlConnection(this.ConnectionString))
            {
                SqlCommand     cmd = new SqlCommand();
                SqlDataAdapter da  = new SqlDataAdapter();
                DataTable      dt  = new DataTable();
                //DataRow dataRow = null;
                try
                {
                    cmd = new SqlCommand("procGetAtmUserDataById", con);
                    cmd.Parameters.Add(new SqlParameter("@Atm_user_ID", userId));
                    //cmd.Parameters.Add(new SqlParameter("@Component_name", componentName));
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Connection.Open();
                    da.SelectCommand = cmd;
                    da.Fill(dt);
                    cmd.Connection.Close();

                    _atmUser.Id            = Convert.ToInt16(dt.Rows[0]["Atm_user_ID"]);
                    _atmUser.Name          = dt.Rows[0]["Name"].ToString();
                    _atmUser.Surname       = dt.Rows[0]["Surname"].ToString();
                    _atmUser.ContactNumber = dt.Rows[0]["Contact_number"].ToString();
                    _atmUser.Email         = dt.Rows[0]["Contact_email"].ToString();
                    _atmUser.Branch        = dt.Rows[0]["Branch"].ToString();
                    _atmUser.Company       = dt.Rows[0]["Company"].ToString();
                    _atmUser.UserType      = dt.Rows[0]["User_type"].ToString();

                    //dataRow = dt.Rows.Count > 0 ? dt.Rows[0] : null;
                }
                catch (Exception x)
                {
                    MessageBox.Show(x.GetBaseException().ToString(), "Error",
                                    MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                finally
                {
                    cmd.Dispose();
                    //pl.MySQLConn.Close();
                }
                return(_atmUser);
            }
        }
示例#8
0
        private void BtnUpdateAtmUser_Click(object sender, EventArgs e)
        {
            try
            {
                if (this.ValidateUpdate())
                {
                    AtmUserModel atmUser = new AtmUserModel()
                    {
                        Id            = this.userId,
                        Name          = txtAtmUserName.Text.Trim(),
                        Surname       = txtAtmUserSurname.Text.Trim(),
                        ContactNumber = txtAtmUserContactNumber.Text.Trim(),
                        Email         = txtAtmUserContactMail.Text.Trim(),
                        Branch        = txtAtmUserBranch.Text.Trim(),
                        Company       = txtAtmUserCompany.Text.Trim(),
                        UserType      = txtAtmUserWorkPlace.Text.Trim(),
                    };

                    var flag = this.userService.UpdateAtmUser(atmUser);

                    if (flag)
                    {
                        this.LoadAtmUsersGridView();

                        MessageBox.Show(
                            Resources.Update_Successful_Message,
                            Resources.Update_Successful_Message_Title,
                            MessageBoxButtons.OK,
                            MessageBoxIcon.Information);
                    }
                }
                else
                {
                    MessageBox.Show(
                        this.errorMessage,
                        Resources.Update_Error_Message_Title,
                        MessageBoxButtons.OK,
                        MessageBoxIcon.Error);
                }
            }
            catch (Exception ex)
            {
                this.ShowErrorMessage(ex);
            }
        }
示例#9
0
        public bool AddRefillOrder(DateTime orderDate, AtmModel atm, AtmUserModel user, int refillNewBill100, int refillNewBill200)
        {
            using (SqlConnection con = new SqlConnection(this.ConnectionString))
            {
                SqlCommand     cmd          = new SqlCommand();
                SqlDataAdapter da           = new SqlDataAdapter();//maknit
                var            rowsAffected = 0;
                try
                {
                    cmd = new SqlCommand("procAddRefillOrder", con);
                    cmd.Parameters.Add(new SqlParameter("@Order_date", orderDate));
                    cmd.Parameters.Add(new SqlParameter("@Atm_ID", atm.Id));
                    cmd.Parameters.Add(new SqlParameter("@Atm_user_ID", user.Id));
                    cmd.Parameters.Add(new SqlParameter("@Refill_new_bill_100", refillNewBill100));
                    cmd.Parameters.Add(new SqlParameter("@Refill_new_bill_200", refillNewBill200));


                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Connection.Open();
                    rowsAffected = cmd.ExecuteNonQuery();
                    cmd.Connection.Close();
                }
                catch (Exception x)
                {
                    MessageBox.Show(x.GetBaseException().ToString(), "Error",
                                    MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                finally
                {
                    cmd.Dispose();
                    //pl.MySQLConn.Close();
                }

                if (rowsAffected > 0)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
        }
示例#10
0
 public bool AddRefillOrder(DateTime orderDate, AtmModel atm, AtmUserModel user, int refillNewBill100, int refillNewBill200)
 {
     return(this.orderAccess.AddRefillOrder(orderDate, atm, user, refillNewBill100, refillNewBill200));
 }
示例#11
0
 public bool AddMalfunctionOrder(DateTime orderDate, AtmModel atm, AtmUserModel user)
 {
     return(this.orderAccess.AddMalfunctionOrder(orderDate, atm, user));
 }
示例#12
0
 public bool UpdateAtmUser(AtmUserModel user)
 {
     return(this.userAccess.UpdateAtmUser(user));
 }
示例#13
0
 public bool AddAtmUser(AtmUserModel user)
 {
     return(this.userAccess.AddAtmUser(user));
 }