Ejemplo n.º 1
0
 private Helper(HelperStatic staticData, int order, HelperType type, double baseCost, List <HelperSkill> skills, bool isInGame, Bitmap image, string version)
 {
     _staticData = staticData;
     Order       = order;
     HelperType  = type;
     BaseCost    = baseCost;
     Skills      = skills.AsReadOnly();
     IsInGame    = isInGame;
     Image       = image;
     FileVersion = version;
 }
Ejemplo n.º 2
0
 private void btnDelete_Click(object sender, EventArgs e)
 {
     try
     {
         using (IDbConnection cnn = new SqlConnection(HelperStatic.LoadConnectionString()))
         {
             string sql = $@"DELETE FROM  EquipmentType  WHERE EquipmentTypeID = {_mainFormEquipmentType.EquipmentTypeID}";
             cnn.Execute(sql);
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Ejemplo n.º 3
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            try
            {
                using (IDbConnection cnn = new SqlConnection(HelperStatic.LoadConnectionString()))
                {
                    string sql = $@"DELETE FROM  EquipmentType  WHERE EquipmentTypeID = {_mainFormEquipmentType.EquipmentTypeID}";
                    cnn.Execute(sql);

                    sql = $@"INSERT INTO [dbo].[EquipmentType] (EquipmentName,X_,Y_)
                        VALUES (@EquipmentName,@X_,@Y_)";
                    cnn.Execute(sql, _mainFormEquipmentType);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Ejemplo n.º 4
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                using (IDbConnection cnn = new SqlConnection(HelperStatic.LoadConnectionString()))
                {
                    string sql     = $@"DELETE FROM  Equipment  WHERE EquipmentID = {_mainFormEquipment.EquipmentID}";
                    int    deleted = cnn.Execute(sql);

                    //INSERT INTO [dbo].[Equipment] (EquipmentID ,EquipmentTypeID,UnitID,Latitude,Longitude,XOffset,YOffset,IsDatum,Tag) VALUES (@EquipmentID ,@EquipmentTypeID2,@UnitID2,@Latitude,@Longitude,@XOffset,@YOffset,@IsDatum,@Tag)
                    sql = $@"INSERT INTO [dbo].[Equipment] (EquipmentTypeID,UnitID,Latitude,Longitude,XOffset,YOffset,IsDatum,Tag) " +
                          $@"VALUES (@EquipmentTypeID,@UnitID,@Latitude,@Longitude,@XOffset,@YOffset,@IsDatum,@Tag)";
                    if (deleted > 0)
                    {
                        cnn.Execute(sql, _mainFormEquipment);
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Ejemplo n.º 5
0
        private void frmEquipment_Load(object sender, EventArgs e)
        {
            #region Binding
            equipmentBindingSource.DataSource = _mainFormEquipment;
            equipmentBindingSource.ResetBindings(true);
            #endregion

            if (firstLoad)
            {
                #region loadAllUnits
                using (IDbConnection cnn = new SqlConnection(HelperStatic.LoadConnectionString()))
                {
                    var p = new DynamicParameters();
                    p.Add("@tblName", "Unit");
                    string sql = "[dbo].[SelectTable]";
                    _AllUnins = cnn.Query <Unit>(sql, p,
                                                 commandType: CommandType.StoredProcedure).ToList();
                }
                #endregion

                #region loadAllEquipmentType
                using (IDbConnection cnn = new SqlConnection(HelperStatic.LoadConnectionString()))
                {
                    var p = new DynamicParameters();
                    p.Add("@tblName", "EquipmentType");
                    string sql = "[dbo].[SelectTable]";
                    _AllEquipmentTypes = cnn.Query <EquipmentType>(sql, p,
                                                                   commandType: CommandType.StoredProcedure).ToList();
                }
                #endregion

                #region loadAllEquipment
                using (IDbConnection cnn = new SqlConnection(HelperStatic.LoadConnectionString()))
                {
                    var p = new DynamicParameters();
                    p.Add("@tblName", "Equipment");
                    string sql = "[dbo].[SelectTable]";
                    _AllEquipments = cnn.Query <Equipment>(sql, p,
                                                           commandType: CommandType.StoredProcedure).ToList();
                }
                #endregion

                #region comboBoxes_Binding
                unitNameComboBox.DataSource =
                    _AllUnins.OrderBy(x => x.UnitName).Select(x => x.UnitName).ToList();

                equipmentNameComboBox.DataSource =
                    _AllEquipmentTypes.OrderBy(x => x.EquipmentName).Select(x => x.EquipmentName).ToList();


                unitNameComboBox.Text = (_AllUnins.Where(x => x.UnitID == _mainFormEquipment.UnitID).FirstOrDefault())
                                        .UnitName;
                equipmentNameComboBox.Text = (_AllEquipmentTypes.Where(x => x.EquipmentTypeID == _mainFormEquipment.EquipmentTypeID).FirstOrDefault())
                                             .EquipmentName;

                this.unitNameComboBox.SelectedIndexChanged      += new EventHandler(this.unitNameComboBox_SelectedIndexChanged);
                this.equipmentNameComboBox.SelectedIndexChanged += new EventHandler(this.equipmentNameComboBox_SelectedIndexChanged);
                #endregion

                firstLoad = false;
            }


            isDatums1 = isDatums();

            if (isDatums1.Count() > 0)
            {
                isValidUintArea1.top    = isDatums1.Min(x => x.YOffset).Value;
                isValidUintArea1.bottom = isDatums1.Max(x => x.YOffset).Value;
                isValidUintArea1.left   = isDatums1.Min(x => x.XOffset).Value;
                isValidUintArea1.right  = isDatums1.Max(x => x.XOffset).Value;

                if (_mainFormEquipment.IsDatum != true)
                {
                    if (!isValidUintArea1.isValid)
                    {
                        _mainFormEquipment.IsDatum = true;
                    }
                    else
                    {
                        _mainFormEquipment.IsDatum  = false;
                        _mainFormEquipment.XPercent = (double)(_mainFormEquipment.XOffset - isValidUintArea1.left) /
                                                      (double)(isValidUintArea1.right - isValidUintArea1.left) * 100;
                        _mainFormEquipment.YPercent = (double)(_mainFormEquipment.YOffset - isValidUintArea1.top) /
                                                      (double)(isValidUintArea1.bottom - isValidUintArea1.top) * 100;

                        isValidUintArea1.topLongitude    = isDatums1.FirstOrDefault(c => c.YOffset == isValidUintArea1.top).Longitude;
                        isValidUintArea1.bottomLongitude = isDatums1.FirstOrDefault(c => c.YOffset == isValidUintArea1.bottom).Longitude;
                        isValidUintArea1.lefLatitudet    = isDatums1.FirstOrDefault(c => c.XOffset == isValidUintArea1.left).Latitude;
                        isValidUintArea1.rightLatitude   = isDatums1.FirstOrDefault(c => c.XOffset == isValidUintArea1.right).Latitude;

                        _mainFormEquipment.Longitude =
                            CalculateLL(convertToDigit(isValidUintArea1.topLongitude),
                                        convertToDigit(isValidUintArea1.bottomLongitude),
                                        _mainFormEquipment.YPercent).ToString();
                        _mainFormEquipment.Latitude =
                            CalculateLL(convertToDigit(isValidUintArea1.lefLatitudet),
                                        convertToDigit(isValidUintArea1.rightLatitude),
                                        _mainFormEquipment.XPercent).ToString();
                    }
                }
            }

            if (_mainFormEquipment.Unit.UnitName != "")
            {
                unitNameComboBox.Text = _mainFormEquipment.Unit.UnitName;
            }
            if (_mainFormEquipment.EquipmentType.EquipmentName != "")
            {
                equipmentNameComboBox.Text = _mainFormEquipment.EquipmentType.EquipmentName;
            }
        }