public void LockFirearm(Firearm gun) { openConn(); using (var cmd = _conn.CreateCommand()) { switch (gun.Type) { case FirearmClass.Shotgun: cmd.CommandText = "exec ЗанятьЕдиницуГс @id"; cmd.Parameters.Add("@id", SqlDbType.Int).Value = gun.PieceId; cmd.ExecuteNonQuery(); break; case FirearmClass.Rifle: cmd.CommandText = "exec ЗанятьЕдиницуНар @id"; cmd.Parameters.Add("@id", SqlDbType.Int).Value = gun.PieceId; cmd.ExecuteNonQuery(); break; case FirearmClass.LessLethal: cmd.CommandText = "exec ЗанятьЕдиницуОооп @id"; cmd.Parameters.Add("@id", SqlDbType.Int).Value = gun.PieceId; cmd.ExecuteNonQuery(); break; case FirearmClass.NotAGun: throw new Exception("Разрешаю и так!"); } } closeConn(); }
public void BindLicense(License lic, Firearm gun) { openConn(); using (var cmd = _conn.CreateCommand()) { switch (gun.Type) { case FirearmClass.Shotgun: cmd.CommandText = "exec ОтпуститьОружиеГс @gunid, @licid"; cmd.Parameters.Add("@gunid", SqlDbType.Int).Value = gun.PieceId; cmd.Parameters.Add("@licid", SqlDbType.VarChar).Value = lic.Number; cmd.ExecuteNonQuery(); break; case FirearmClass.Rifle: cmd.CommandText = "exec ОтпуститьОружиеНар @gunid, @licid"; cmd.Parameters.Add("@gunid", SqlDbType.Int).Value = gun.PieceId; cmd.Parameters.Add("@licid", SqlDbType.VarChar).Value = lic.Number; cmd.ExecuteNonQuery(); break; case FirearmClass.LessLethal: cmd.CommandText = "exec ОтпуститьОружиеОооп @gunid, @licid"; cmd.Parameters.Add("@gunid", SqlDbType.Int).Value = gun.PieceId; cmd.Parameters.Add("@licid", SqlDbType.VarChar).Value = lic.Number; cmd.ExecuteNonQuery(); break; case FirearmClass.NotAGun: throw new Exception("Разрешаю и так!"); } } closeConn(); }
public void AddFirearmToOrder(int orderId, Firearm gun) { openConn(); using (var cmd = _conn.CreateCommand()) { switch (gun.Type) { case FirearmClass.Shotgun: cmd.CommandText = "exec ДобавитьГсВЗаказ @gunid, @orderid"; cmd.Parameters.Add("@gunid", SqlDbType.Int).Value = gun.PieceId; cmd.Parameters.Add("@orderid", SqlDbType.Int).Value = orderId; cmd.ExecuteNonQuery(); break; case FirearmClass.Rifle: cmd.CommandText = "exec ДобавитьНарВЗаказ @gunid, @orderid"; cmd.Parameters.Add("@gunid", SqlDbType.Int).Value = gun.PieceId; cmd.Parameters.Add("@orderid", SqlDbType.Int).Value = orderId; cmd.ExecuteNonQuery(); break; case FirearmClass.LessLethal: cmd.CommandText = "exec ДобавитьОоопВЗаказ @gunid, @orderid"; cmd.Parameters.Add("@gunid", SqlDbType.Int).Value = gun.PieceId; cmd.Parameters.Add("@orderid", SqlDbType.Int).Value = orderId; cmd.ExecuteNonQuery(); break; case FirearmClass.NotAGun: throw new Exception("Разрешаю и так!"); } } closeConn(); }
private License AskForLicense(Firearm f) { License lic = new License(f.Type); LicenseEntryPopupForm licForm = new LicenseEntryPopupForm(f, lic); licForm.ShowDialog(); return(lic); }
public int GetFirearmIdForAnOrder(int orderId, Firearm gun) { openConn(); int i = -1; using (var cmd = _conn.CreateCommand()) { switch (gun.Type) { case FirearmClass.Shotgun: cmd.CommandText = "exec НомерЕдиницыВЗаказеГс @oid @tid @id output"; cmd.Parameters.Add("@oid", SqlDbType.Int).Value = orderId; cmd.Parameters.Add("@tid", SqlDbType.Int).Value = gun.TypeId; cmd.Parameters.Add("@id", SqlDbType.Int); cmd.Parameters["@id"].Direction = ParameterDirection.Output; cmd.ExecuteNonQuery(); i = Convert.ToInt32(cmd.Parameters["@id"].Value); break; case FirearmClass.Rifle: cmd.CommandText = "exec НомерЕдиницыВЗаказеНар @oid @tid @id output"; cmd.Parameters.Add("@oid", SqlDbType.Int).Value = orderId; cmd.Parameters.Add("@tid", SqlDbType.Int).Value = gun.TypeId; cmd.Parameters.Add("@id", SqlDbType.Int); cmd.Parameters["@id"].Direction = ParameterDirection.Output; cmd.ExecuteNonQuery(); i = Convert.ToInt32(cmd.Parameters["@id"].Value); break; case FirearmClass.LessLethal: cmd.CommandText = "exec НомерЕдиницыВЗаказеОооп @oid @tid @id output"; cmd.Parameters.Add("@oid", SqlDbType.Int).Value = orderId; cmd.Parameters.Add("@tid", SqlDbType.Int).Value = gun.TypeId; cmd.Parameters.Add("@id", SqlDbType.Int); cmd.Parameters["@id"].Direction = ParameterDirection.Output; cmd.ExecuteNonQuery(); i = Convert.ToInt32(cmd.Parameters["@id"].Value); break; case FirearmClass.NotAGun: throw new Exception("Разрешаю и так!"); } } closeConn(); return(i); }
public LicenseEntryPopupForm(Firearm f, License lic) { InitializeComponent(); currentGun = f; tempLic = lic; headLabel.Text = $"Добавление лицензии для {currentGun.Name} в заказе {currentGun.TypeId}"; switch (currentGun.Type) { case FirearmClass.Shotgun: label6.Text = "Гладкоствольное оружие"; break; case FirearmClass.Rifle: label6.Text = "Нарезное оружие"; break; case FirearmClass.LessLethal: label6.Text = "ОООП"; break; } }