Example #1
0
        private void dvgAllAtmsEditing_SelectionChanged(object sender, EventArgs e)
        {
            DataGridView dgv = (DataGridView)sender;

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

                    AtmModel atmData = this.atmService.GetAtmData(atmId);

                    txtAtmName.Text             = atmData.Name.ToString();
                    txtAtmSerialNumber.Text     = atmData.SerialNumber.ToString();
                    txtAtmModel.Text            = atmData.Model.ToString();
                    txtAtmAddress.Text          = atmData.Address.ToString();
                    txtAtmLocation.Text         = atmData.Location.ToString();
                    txtAtmAccountingNumber.Text = atmData.AccountingNumber.ToString();
                }
            }
            catch (Exception ex)
            {
                this.ShowErrorMessage(ex);
            }
        }
Example #2
0
        private void btnSplineTest_Click(object sender, EventArgs e)
        {
            chartAtmRefillTrend.ResetText();



            //chartAtmRefill.Series[0].XValueType = ChartValueType.DateTime;
            chartAtmRefillTrend.ChartAreas[0].AxisX.LabelStyle.Format = "yyyy-MM-dd";
            chartAtmRefillTrend.ChartAreas[0].AxisX.Interval          = 1;
            chartAtmRefillTrend.ChartAreas[0].AxisX.IntervalType      = DateTimeIntervalType.Months;
            chartAtmRefillTrend.ChartAreas[0].AxisX.IntervalOffset    = 1;

            //chartAtmRefill.Series[0].XValueType = ChartValueType.DateTime;
            DateTime minDate = new DateTime(2018, 03, 01).AddSeconds(-1);
            DateTime maxDate = DateTime.Now;    // or DateTime.Now;

            chartAtmRefillTrend.ChartAreas[0].AxisX.Minimum = minDate.ToOADate();
            chartAtmRefillTrend.ChartAreas[0].AxisX.Maximum = maxDate.ToOADate();
            chartAtmRefillTrend.ChartAreas[0].AxisY.Maximum = 700000;


            AtmModel atm1 = new AtmModel();

            atm1.Id = 2;
            var currentAtmRefills = this.orderService.GetAllAtmRefillOrders(atm1);


            foreach (var item in currentAtmRefills)
            {
                this.chartAtmRefillTrend.Series[0].Points.AddXY(item.OrderDate, (item.RefillNewBill100 * 100) + (item.RefillNewBill200 * 200));
            }
        }
Example #3
0
        public AtmModel GetAtmByOrderId(int orderId)
        {
            //string test = "2018-01-01";
            //DateTime dTime = DateTime.ParseExact(test, "yyyy-MM-dd", CultureInfo.InvariantCulture);

            DataTable data = new DataTable();
            AtmModel  _atm = new AtmModel();


            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("procGetAtmByOrderId", con);
                    cmd.Parameters.Add(new SqlParameter("@Order_ID", orderId));
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Connection.Open();
                    da.SelectCommand = cmd;
                    da.Fill(dt);
                    cmd.Connection.Close();



                    _atm.Id           = Convert.ToInt16(dt.Rows[0]["Atm_ID"]);
                    _atm.Name         = dt.Rows[0]["Atm_name"].ToString();
                    _atm.SerialNumber = dt.Rows[0]["Atm_serial_number"].ToString();
                    _atm.Model        = dt.Rows[0]["Atm_model"].ToString();
                    _atm.Address      = dt.Rows[0]["Atm_address"].ToString();
                    _atm.Location     = dt.Rows[0]["Atm_location"].ToString();
                    // TO DO Fali mi status
                    _atm.AccountingNumber = Convert.ToInt32(dt.Rows[0]["Atm_accounting_number"]);



                    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(_atm);
            }
        }
Example #4
0
        public IActionResult NovoCadastro(int?id)
        {
            AtmModel atm = null;

            if (id.HasValue)
            {
                atm = _atmService.GetById(id.Value);
            }

            LoadDropDowns(atm);

            return(View(atm));
        }
Example #5
0
        public IActionResult AtualizarCadastro(AtmModel atm)
        {
            try
            {
                _atmService.Update(atm);
            }
            catch (Exception ex)
            {
                _log.LogError("Erro ao atualizar Atm", ex);
                return(BadRequest("Erro ao atualizar Atm. Tente novamente"));
            }

            return(Json(""));
        }
Example #6
0
        public IActionResult Cadastrar(AtmModel atm)
        {
            try
            {
                _atmService.Insert(atm);
            }
            catch (Exception ex)
            {
                _log.LogError("Erro ao salvar Atm", ex);
                return(BadRequest("Erro ao salvar Atm. Tente novamente"));
            }

            return(Json(""));
        }
Example #7
0
        }//End GetAllAtms

        public List <AtmModel> GetAllAtmsList()
        {
            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 <AtmModel> _atms = new List <AtmModel>();

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

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

                    foreach (DataRow row in dt.Rows)
                    {
                        AtmModel _atm = new AtmModel();
                        _atm.Id               = Convert.ToInt32(row["Atm_ID"]);
                        _atm.Name             = row["Atm_name"].ToString();
                        _atm.SerialNumber     = row["Atm_serial_number"].ToString();
                        _atm.Model            = row["Atm_model"].ToString();
                        _atm.Address          = row["Atm_address"].ToString();
                        _atm.Location         = row["Atm_location"].ToString();
                        _atm.Status           = row["Atm_status"].ToString();
                        _atm.AccountingNumber = Convert.ToInt32(row["Atm_accounting_number"]);
                        _atms.Add(_atm);
                    }
                }
                catch (Exception x)
                {
                    MessageBox.Show(x.GetBaseException().ToString(), "Error",
                                    MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                finally
                {
                    cmd.Dispose();
                    //pl.MySQLConn.Close();
                }
                return(_atms);
            }
        }//End GetAllAtmsList
Example #8
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
            }
        }
Example #9
0
        /// <summary>
        ///
        /// </summary>
        /// <returns>Data table</returns>
        public int AddAtm(AtmModel atm)
        {
            using (SqlConnection con = new SqlConnection(this.ConnectionString))
            {
                SqlCommand     cmd          = new SqlCommand();
                SqlDataAdapter da           = new SqlDataAdapter();//maknit
                var            rowsAffected = 0;
                int            index        = 0;
                try
                {
                    cmd = new SqlCommand("procAddAtm", con);

                    cmd.Parameters.Add(new SqlParameter("@Atm_name", atm.Name));
                    cmd.Parameters.Add(new SqlParameter("@Atm_serial_number", atm.SerialNumber));
                    cmd.Parameters.Add(new SqlParameter("@Atm_model", atm.Model));
                    cmd.Parameters.Add(new SqlParameter("@Atm_address", atm.Address));
                    cmd.Parameters.Add(new SqlParameter("@Atm_location", atm.Location));
                    cmd.Parameters.Add(new SqlParameter("@Atm_status", atm.Status));
                    cmd.Parameters.Add(new SqlParameter("@Atm_accounting_number", atm.AccountingNumber));
                    cmd.Parameters.Add("@new_id", SqlDbType.Int, 30);
                    cmd.Parameters["@new_id"].Direction = ParameterDirection.Output;

                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Connection.Open();
                    rowsAffected = cmd.ExecuteNonQuery();
                    cmd.Connection.Close();
                    index = Convert.ToInt32(cmd.Parameters["@new_id"].Value);
                }
                catch (Exception x)
                {
                    MessageBox.Show(x.GetBaseException().ToString(), "Error",
                                    MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                finally
                {
                    cmd.Dispose();
                    //pl.MySQLConn.Close();
                }

                if (index > 0)
                {
                    return(index);
                }
                else
                {
                    return(-1);
                }
            }
        }
        public AtmModel GetById(int id)
        {
            AtmModel obj = null;

            try
            {
                obj = DbSet.FirstOrDefault(x => x.id == id);
            }
            catch (Exception ex)
            {
                _log.LogError(ex.Message, ex);
            }

            return(obj);
        }
        public AtmModel GetByPc(string pc)
        {
            AtmModel obj = null;

            try
            {
                obj = DbSet.FirstOrDefault(x => x.AtmPc == pc);
            }
            catch (Exception ex)
            {
                _log.LogError(ex.Message, ex);
            }

            return(obj);
        }
        public bool Insert(AtmModel obj)
        {
            try
            {
                DbSet.Add(obj);
                Db.SaveChanges();
            }
            catch (Exception ex)
            {
                _log.LogError(ex.Message, ex);
                return(false);
            }

            return(true);
        }
Example #13
0
        public List <RefillModel> GetAllAtmRefillOrders(AtmModel atm)
        {
            var allAtmsRefill      = GetAllAtmsRefillOrders();
            var allAtmRefillOrders = new List <RefillModel>();

            foreach (var item in allAtmsRefill)
            {
                if (item.ATM.Id == atm.Id)
                {
                    allAtmRefillOrders.Add(item);
                }
            }

            return(allAtmRefillOrders);
        }
        public bool Update(AtmModel obj)
        {
            try
            {
                Db.Entry(DbSet.FirstOrDefault(x => x.id == obj.id)).CurrentValues.SetValues(obj);
                Db.SaveChanges();
            }
            catch (Exception ex)
            {
                _log.LogError(ex.Message, ex);
                return(false);
            }

            return(true);
        }
Example #15
0
        }//End GetAllAtmsList

        public bool UpdateAtm(AtmModel atm)
        {
            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("procUpdateAtm", con);
                    cmd.Parameters.Add(new SqlParameter("@Atm_ID", atm.Id));
                    cmd.Parameters.Add(new SqlParameter("@Atm_name", atm.Name));
                    cmd.Parameters.Add(new SqlParameter("@Atm_serial_number", atm.SerialNumber));
                    cmd.Parameters.Add(new SqlParameter("@Atm_model", atm.Model));
                    cmd.Parameters.Add(new SqlParameter("@Atm_address", atm.Address));
                    cmd.Parameters.Add(new SqlParameter("@Atm_location", atm.Location));
                    cmd.Parameters.Add(new SqlParameter("@Atm_status", atm.Status));
                    cmd.Parameters.Add(new SqlParameter("@Atm_accounting_number", atm.AccountingNumber));



                    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);
                }
            }
        }
Example #16
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);
        }
Example #17
0
        public AtmModel GetAtmData(int atmId)
        {
            DataTable data = new DataTable();
            //DataRow dataRow;
            AtmModel _atm = new AtmModel();

            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("procGetAtmById", con);
                    cmd.Parameters.Add(new SqlParameter("@Atm_ID", atmId));
                    //cmd.Parameters.Add(new SqlParameter("@Component_name", componentName));
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Connection.Open();
                    da.SelectCommand = cmd;
                    da.Fill(dt);
                    cmd.Connection.Close();

                    _atm.Id           = Convert.ToInt16(dt.Rows[0]["Atm_ID"]);
                    _atm.Name         = dt.Rows[0]["Atm_name"].ToString();
                    _atm.SerialNumber = dt.Rows[0]["Atm_serial_number"].ToString();
                    _atm.Model        = dt.Rows[0]["Atm_model"].ToString();
                    _atm.Address      = dt.Rows[0]["Atm_address"].ToString();
                    _atm.Location     = dt.Rows[0]["Atm_location"].ToString();
                    // TO DO Fali mi status
                    _atm.AccountingNumber = Convert.ToInt32(dt.Rows[0]["Atm_accounting_number"]);

                    //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(_atm);
            }
        }
Example #18
0
        private void btnUpdateAtmData_Click(object sender, EventArgs e)
        {
            try
            {
                if (this.ValidateUpdate())
                {
                    AtmModel atmModel = new AtmModel()
                    {
                        Id               = this.atmId,
                        Name             = txtAtmName.Text.Trim(),
                        SerialNumber     = txtAtmSerialNumber.Text.Trim(),
                        Model            = txtAtmModel.Text.Trim(),
                        Address          = txtAtmAddress.Text.Trim(),
                        Location         = txtAtmLocation.Text.Trim(),
                        AccountingNumber = txtAtmAccountingNumber.Text.Trim() == string.Empty ? 0 : Convert.ToInt32(txtAtmAccountingNumber.Text),
                        Status           = "U funkciji",
                    };

                    var flag = this.atmService.UpdateAtm(atmModel);


                    if (flag)
                    {
                        this.LoadAtmsGridView();

                        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);
            }
        }
Example #19
0
        public bool AddAtmComponents(AtmModel atm)
        {
            if (atm.Id != 0)
            {
                foreach (var component in atm.components)
                {
                    AddAtmComponent(atm, component);
                }


                return(true);
            }
            else
            {
                return(false);
            }
        }
Example #20
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);
                }
            }
        }
Example #21
0
        public void CreateAtm(Client sender)
        {
            if (!sender.HasRank(ServerRank.AdministratorRozgrywki2))
            {
                sender.SendWarning("Nie posiadasz uprawnień do dodawania bankomatu.");
                return;
            }

            sender.SendInfo("Ustaw się w wybranej pozycji, a następnie wpisz \"tu\".");

            void Handler(Client o, string message)
            {
                if (o == sender && message == "tu")
                {
                    AtmModel data = new AtmModel
                    {
                        CreatorForumName = o.GetAccountEntity().DbModel.Name,
                        Position         = new FullPosition
                        {
                            Position = new Vector3
                            {
                                X = o.Position.X,
                                Y = o.Position.Y,
                                Z = o.Position.Z
                            },

                            Rotation = new Vector3
                            {
                                X = o.Rotation.X,
                                Y = o.Rotation.Y,
                                Z = o.Rotation.Z
                            }
                        }
                    };
                    XmlHelper.AddXmlObject(data, Path.Combine(Utils.XmlDirectory, nameof(AtmModel)));
                    AtmEntity atm = new AtmEntity(data);
                    atm.Spawn();
                    EntityHelper.Add(atm);
                    sender.SendInfo("Dodawanie bankomatu zakończyło się pomyślnie.");
                }
            }
        }
Example #22
0
 public int AddAtm(AtmModel atm)
 {
     return(this.atmAccess.AddAtm(atm));
 }
Example #23
0
 public bool AddMalfunctionOrder(DateTime orderDate, AtmModel atm, AtmUserModel user)
 {
     return(this.orderAccess.AddMalfunctionOrder(orderDate, atm, user));
 }
Example #24
0
 public bool AddRefillOrder(DateTime orderDate, AtmModel atm, AtmUserModel user, int refillNewBill100, int refillNewBill200)
 {
     return(this.orderAccess.AddRefillOrder(orderDate, atm, user, refillNewBill100, refillNewBill200));
 }
Example #25
0
 public AtmEntity(AtmModel data)
 {
     Data = data;
 }
Example #26
0
 public AtmMainView()
 {
     InitializeComponent();
     this.model = new AtmModel();
 }
Example #27
0
        private void LoadDropDowns(AtmModel atm)
        {
            var ufList = _ufService.Select();
            List <SelectListItem> dropDownUfList = new List <SelectListItem>();

            if (ufList.Any())
            {
                dropDownUfList = _ufService.Select().Select(x =>
                {
                    bool isSelected = false;
                    if (atm != null)
                    {
                        isSelected = atm.AtmUf == x.id;
                    }

                    return(new SelectListItem()
                    {
                        Text = x.UfNome,
                        Value = x.id.ToString(),
                        Selected = isSelected
                    });
                }).ToList();

                //ADD DEFAULT
                dropDownUfList.Insert(0, new SelectListItem()
                {
                    Text = "", Value = ""
                });

                ViewBag.Estados = dropDownUfList;
            }


            var cityList = _municipioService.Select();
            List <SelectListItem> dropDownCityList = new List <SelectListItem>();


            if (cityList.Any())
            {
                dropDownCityList = _municipioService.Select().Select(x =>
                {
                    bool isSelected = false;
                    if (atm != null)
                    {
                        isSelected = atm.AtmCidade == x.id;
                    }

                    return(new SelectListItem()
                    {
                        Text = x.MunNome,
                        Value = x.id.ToString(),
                        Selected = isSelected
                    });
                }).ToList();

                //ADD DEFAULT
                dropDownCityList.Insert(0, new SelectListItem()
                {
                    Text = "", Value = ""
                });

                ViewBag.Municipios = dropDownCityList;
            }
        }
Example #28
0
 public bool UpdateAtm(AtmModel atm)
 {
     return(this.atmAccess.UpdateAtm(atm));
 }
Example #29
0
 public bool UpdateAtmComponent(AtmModel atm, AtmComponentModel atmComponent)
 {
     return(this.atmAccess.UpdateAtmComponent(atm, atmComponent));
 }
Example #30
0
 public bool AddAtmComponent(AtmModel atm, AtmComponentModel atmComponent)
 {
     return(this.atmAccess.AddAtmComponent(atm, atmComponent));
 }