Пример #1
0
 public bool HasStatModifier(Const.Stats stat)
 {
     var mod = this.StatsModifiers.Find(x =>{
         return stat == x.Stat;
     });
     return mod != null;
 }
Пример #2
0
    private void CreateStatsCell(Const.Stats stat, string value, CharacterStatBuffState state)
    {
        var go = this.CreateCell();

        var cell = go.GetComponent<CharacterStatCell>();
        cell.Init(stat, value, state);
    }
Пример #3
0
 public double GetStat(Const.Stats key)
 {
     if (_stats.ContainsKey(key))
     {
         return _stats[key];
     }
     return 0d;
 }
 public double GetAffinity(Const.Affinities key)
 {
     if (_affinities.ContainsKey(key))
     {
         return _affinities[key];
     }
     return 0;
 }
Пример #5
0
 /// <summary>
 /// 메시지를 수신했을 때 호출된다.
 /// 파라미터로 넘어온 버퍼는 워커 스레드에서 재사용 되므로 복사한 뒤 어플리케이션으로 넘겨준다.
 /// </summary>
 /// <param name="buffer"></param>
 void IPeer.on_message(Const<byte[]> buffer)
 {
     // 버퍼를 복사한 뒤 CPacket클래스로 감싼 뒤 넘겨준다.
     // CPacket클래스 내부에서는 참조로만 들고 있는다.
     byte[] app_buffer = new byte[buffer.Value.Length];
     Array.Copy(buffer.Value, app_buffer, buffer.Value.Length);
     CPacket msg = new CPacket(app_buffer, this);
     (this.freenet_eventmanager.Target as CFreeNetEventManager).enqueue_network_message(msg);
 }
 public void SetAffinity(Const.Affinities affinity, double value)
 {
     if (_affinities.ContainsKey(affinity))
     {
         _affinities[affinity] = value;
     }
     else
     {
         _affinities.Add(affinity, value);
     }
 }
Пример #7
0
 public void SetStat(Const.Stats stat, double value)
 {
     if (_stats.ContainsKey(stat))
     {
         _stats[stat] = value;
     }
     else
     {
         _stats.Add(stat, value);
     }
 }
Пример #8
0
 /// <summary>
 /// Gets a position to cast a skill on so that the skill can hit the target character
 /// </summary>
 /// <returns>The position to hit character with skill.</returns>
 /// <param name="skill">Skill.</param>
 /// <param name="skillRadius">Skill radius.</param>
 /// <param name="target">Target.</param>
 /// <param name="sourceTeam">Source team.</param>
 /// <param name="map">The full map.</param>
 private MapPosition GetPositionToHitCharacterWithSkill(Skill skill, List<MapPosition> skillRadius, BattleCharacter target, Const.Team sourceTeam, Dictionary<MapPosition, Tile> map)
 {
     foreach (var mapPosition in skillRadius)
     {
         var targeting = skill.Effects[0].EffectTarget;
         var affectedPositions = ServiceFactory.GetMapService().GeMapPositionsForPattern(targeting.Pattern, targeting.TargetGroup, sourceTeam, map, mapPosition);
         if (affectedPositions.Intersect(target.OccupiedMapPositions).Count() > 0)
         {
             return mapPosition;
         }
     }
     return null;
 }
 protected internal override void TraverseConst(Const @const)
 {
     if (@const.Value == null)
     {
         _writer.Write("null");
     }
     else
     {
         var value = @const.Value.UndecorateNullable();
         if (value.GetType().IsNumeric())
         {
             _writer.Write(value.ToInvariantString());
         }
         else if (value is bool)
         {
             _writer.Write(value.ToInvariantString().ToLower());
         }
         else if (value is char)
         {
             _writer.Write((char)value);
         }
         else if (value is String)
         {
             _writer.Write(((String)value).Quote());
         }
         else if (value is Type)
         {
             var t = (Type)value;
             var s_t = t.GetCSharpRef(ToCSharpOptions.Informative);
             _writer.Write("typeof({0})", s_t);
         }
         else if (value is FieldInfo)
         {
             var f = (FieldInfo)value;
             var s_f = f.GetCSharpRef(ToCSharpOptions.Informative);
             _writer.Write("fieldof({0})", s_f);
         }
         else if (value is MethodBase)
         {
             var m = (MethodBase)value;
             var s_m = m.GetCSharpRef(ToCSharpOptions.Informative);
             _writer.Write("methodof({0})", s_m);
         }
         else
         {
             _writer.Write("{");
             _writer.Write(value);
             _writer.Write("}");
         }
     }
 }
Пример #10
0
        public static async Task <Tuple <IList <SnapshotRule>, string> > LoadLatestRules()
        {
            string appData             = Const.GetAppDataFolderPath();
            string latestRulesFileName = GetLatestRulesFileName(appData);

            IList <SnapshotRule> rules = latestRulesFileName == null
        ? new List <SnapshotRule>()
        : (await SafeLoadJson <IEnumerable <SnapshotRule> >(Path.Combine(appData, latestRulesFileName))).ToList();

            return(new Tuple <IList <SnapshotRule>, string>(
                       rules,
                       latestRulesFileName
                       ));
        }
Пример #11
0
        public void SumOpDerivative()
        {
            var x  = new Const <float>(BuilderInstance <float> .Volume.From(new float[] { 1.0f, 2.0f, 3.0f }, new Shape(3)), "x");
            var op = new Sum <float>(x, new Shape(1));

            using (var session = new Session <float>())
            {
                session.Differentiate(op);

                op.Derivate = new Const <float>(50.0f, "50");

                var result = x.Derivate.Evaluate(session);
            }
        }
Пример #12
0
        int AddConstant(float constant, string type)
        {
            Const tempConst = ConstantList.Find(x => x._Const == constant);

            if (tempConst == null)
            {
                ConstantList.Add(new Const(constant, ConstantList.Count, type));
                return(ConstantList.Count - 1);
            }
            else
            {
                return(tempConst.Index);
            }
        }
Пример #13
0
 public override void LoopContent()
 {
     //假如1个周期过去PLC可读或可写有任意一个为false,则代表出现错误,否则无问题
     Const.OpcDatasource.PlcErrorOccured = !Const.OpcDatasource.PlcReadable || !Const.OpcDatasource.PlcWritable;
     if (Const.OpcDatasource.PlcErrorOccured)
     {
         Const.WriteConsoleLog("PLC出现故障,PLC Error Occured:true");
         //Const.WriteConsoleLog("准备重启操作系统...");
         //ExitWindowsUtils.Reboot(true);
     }
     Const.OpcDatasource.PlcReadable = false;
     Const.OpcDatasource.PlcWritable = false;
     //throw new NotImplementedException();
 }
Пример #14
0
        protected override void TraverseConst(Const @const)
        {
            var v = @const.Value;
            var t = @const.Type;

            if (v == null)
            {
                il.ldnull();
            }
            else
            {
                if (t == typeof(bool))
                {
                    if ((bool)v)
                    {
                        il.ldtrue();
                    }
                    else
                    {
                        il.ldfalse();
                    }
                }
                else if (t == typeof(int) || t == typeof(uint))
                {
                    unchecked
                    {
                        il.ldc_i4((int)v);
                    }
                }
                else if (t == typeof(long) || t == typeof(long))
                {
                    unchecked
                    {
                        il.ldc_i8((long)v);
                    }
                }
                else if (t == typeof(float))
                {
                    il.ldc_r4((float)v);
                }
                else if (t == typeof(double))
                {
                    il.ldc_r8((double)v);
                }
                else
                {
                    throw new NotImplementedException();
                }
            }
        }
Пример #15
0
 void OnTriggerEnter(Collider other)
 {
     if (other.tag == "Player" || other.tag == "NPC")
     {
         DamageData ddNPC = Const.SetNPCDamageData(index, Const.aiState.Attack1, ownedBy);
         ddNPC.other          = gameObject;
         ddNPC.attacknormal   = Vector3.Normalize(other.transform.position - transform.position);
         ddNPC.impactVelocity = impactMelee;
         float take = Const.a.GetDamageTakeAmount(ddNPC);
         take         = (take / meleeColliderCounter);   //split it for multiple tap melee attacks, e.g. double paw swipe
         ddNPC.damage = take;
         other.GetComponent <HealthManager>().TakeDamage(ddNPC);
     }
 }
Пример #16
0
        public void SoftmaxCrossEntropy()
        {
            var softmax = new Const <double>(1.0, "softmax");
            var y       = new Const <double>(1.0, "y");
            var op      = new SoftmaxCrossEntropy <double>(softmax, y);

            var xml          = op.ToXml();
            var deserialized = SerializationExtensions.FromXml <double>(xml) as SoftmaxCrossEntropy <double>;

            Assert.IsNotNull(deserialized);
            Assert.AreEqual(2, deserialized.Parents.Count);
            Assert.AreEqual("softmax", (deserialized.Parents[0] as Const <double>).Name);
            Assert.AreEqual("y", (deserialized.Parents[1] as Const <double>).Name);
        }
Пример #17
0
        public void Div()
        {
            var a  = new Const <double>(1.0, "one");
            var b  = new Const <double>(2.0, "two");
            var op = new Div <double>(a, b);

            var xml          = op.ToXml();
            var deserialized = SerializationExtensions.FromXml <double>(xml) as Div <double>;

            Assert.IsNotNull(deserialized);
            Assert.AreEqual(2, deserialized.Parents.Count);
            Assert.AreEqual("one", (deserialized.Parents[0] as Const <double>).Name);
            Assert.AreEqual("two", (deserialized.Parents[1] as Const <double>).Name);
        }
Пример #18
0
        public void Reshape2()
        {
            var x     = new Const <double>(1.0, "x");
            var shape = new Const <double>(new[] { 1.0, 2.0, 3.0, 4.0 }, "shape");
            var op    = new Reshape <double>(x, shape);

            var xml          = op.ToXml();
            var deserialized = SerializationExtensions.FromXml <double>(xml) as Reshape <double>;

            Assert.IsNotNull(deserialized);
            Assert.AreEqual(2, deserialized.Parents.Count);
            Assert.AreEqual("x", (deserialized.Parents[0] as Const <double>).Name);
            Assert.AreEqual("shape", (deserialized.Parents[1] as Const <double>).Name);
        }
Пример #19
0
 public IActionResult Login(string UserName, string Pwd)
 {
     if (!string.IsNullOrEmpty(UserName) && !string.IsNullOrEmpty(Pwd))
     {
         return(Ok(new
         {
             token = Const.GetToken(UserName)
         }));
     }
     else
     {
         return(BadRequest(new { message = "username or password is incorrect." }));
     }
 }
Пример #20
0
        /// <summary>
        /// solves ax3 + bx2 + cx + d
        /// </summary>
        /// <param name="a">
        /// Coefficient of x^3
        /// </param>
        /// <param name="b">
        /// Coefficient of x^2
        /// </param>
        /// <param name="c">
        /// Coefficient of x
        /// </param>
        /// <param name="d">
        /// Free coefficient
        /// </param>
        /// <returns>
        /// Set of roots
        /// </returns>
        internal static Set SolveCubic(Entity a, Entity b, Entity c, Entity d)
        {
            // en: https://en.wikipedia.org/wiki/Cubic_equation
            // ru: https://ru.wikipedia.org/wiki/%D0%A4%D0%BE%D1%80%D0%BC%D1%83%D0%BB%D0%B0_%D0%9A%D0%B0%D1%80%D0%B4%D0%B0%D0%BD%D0%BE

            // TODO (to remove sympy code!)

            Set res;

            if (TreeAnalyzer.IsZero(d))
            {
                res = SolveQuadratic(a, b, c);
                res.Add(0);
                return(res);
            }

            if (TreeAnalyzer.IsZero(a))
            {
                return(SolveQuadratic(b, c, d));
            }

            res = new Set();

            var coeff = MathS.i * MathS.Sqrt(3) / 2;

            var u1 = new NumberEntity(1);
            var u2 = SySyn.Rational(-1, 2) + coeff;
            var u3 = SySyn.Rational(-1, 2) - coeff;
            var D0 = MathS.Sqr(b) - 3 * a * c;
            var D1 = (2 * MathS.Pow(b, 3) - 9 * a * b * c + 27 * MathS.Sqr(a) * d).InnerSimplify();
            var C  = MathS.Pow((D1 + MathS.Sqrt(MathS.Sqr(D1) - 4 * MathS.Pow(D0, 3))) / 2, Number.CreateRational(1, 3));

            foreach (var uk in new List <Entity> {
                u1, u2, u3
            })
            {
                Entity r;
                if (Const.EvalIfCan(C) == 0 && Const.EvalIfCan(D0) == 0)
                {
                    r = -(b + uk * C) / 3 / a;
                }
                else
                {
                    r = -(b + uk * C + D0 / C / uk) / 3 / a;
                }
                res.Add(r);
            }
            return(res);
        }
Пример #21
0
 public bool IsInTargetGroup(Const.SkillTargetGroup targetGroup, Const.Team source, Const.Team target)
 {   
     switch (targetGroup)
     {
         case Const.SkillTargetGroup.All:
             return true;
         case Const.SkillTargetGroup.Ally:
         case Const.SkillTargetGroup.Self:
             return source == target;
         case Const.SkillTargetGroup.Opponent:
             return source != target;
         default:
             return false;
     }
 }
Пример #22
0
 /// <summary>
 /// Ajoute au fichier correspondant une sauvegarde des données entrées dans l'application.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void btnCloture_Click(object sender, EventArgs e)
 {
     // S'il n'y a pas de budget
     if (lstAccounts.Items.Count != 0)
     {
         if ((MessageBox.Show(Const.MSG_VALIDATIONMONYLYSAVE(dtpMonth.Value), Const.MSG_TITLE_VALIDATIONMONYLYSAVE, MessageBoxButtons.YesNo) == DialogResult.Yes))
         {
             controler.finalizeMonthDialogs(controler.formatDate(dtpMonth.Value.Date));
         }
     }
     else
     {
         MessageBox.Show(Const.MSG_ERR_FINALIZE, Const.ERROR, MessageBoxButtons.OK);
     }
 }
Пример #23
0
    public combinedHeightHeat(IMap heightMap, IMap heatMap, worldChunkSettings chunkSettings)
    {
        Const  black        = new Const(-1);
        Select heightselect = new Select(heightMap.GetCache(), black, heightMap.GetCache());

        heightselect.SetBounds(.5, 1, .2);
        this.combo = new Add(heatMap.GetCache(), heightselect);
        //Invert invert = new Invert(combo);

        Noise2D final = new Noise2D(chunkSettings.mapWidth, chunkSettings.mapHeight, combo);

        final.GeneratePlanar(chunkSettings.left, chunkSettings.right, chunkSettings.top, chunkSettings.bottom, isSeamless: true);
        combinedCache = new Cache(combo);
        noiseData     = final.GetData();
    }
Пример #24
0
        public async Task <IActionResult> UserChalenge(string phoneNumber)
        {
            if (!phoneNumber.IsValidIranianMobileNumber())
            {
                ViewBag.msg = "شماره تلفن همراه معتبر نمی باشد";
                return(View());
            }
            string token = Const.GeneratRandomNumber();

            await AddCashAsync(phoneNumber, token, 3);

            await _notify.SendNotifyWithTemplateAsync(phoneNumber, token, MessageTemplate.Bisroverify);

            return(RedirectToAction(nameof(ValidateingNumber), new { phoneNumber }));
        }
        void IPeer.on_message(Const <byte[]> buffer)
        {
            CPacket  msg         = new CPacket(buffer.Value, this);
            PROTOCOL protocol_id = (PROTOCOL)msg.pop_protocol_id();

            switch (protocol_id)
            {
            case PROTOCOL.CHAT_MSG_ACK:
            {
                string text = msg.pop_string();
                Console.WriteLine(string.Format("text {0}", text));
            }
            break;
            }
        }
Пример #26
0
    public UnitAction GetAction(Unit unit, Game game, AiCup2019.Debug debug)
    {
        if (m_lastTick >= game.CurrentTick) // Verify this number
        {
            //TODO: Check number of bullets
            LogService.WriteLine("Cached choice");
            return(CreateAction(m_lastGame.Units.First(u => u.unit.Id == unit.Id), m_lastGame));
        }

        Const.Reset(game.Properties, game);
        Debug = debug;
        var myGame = new MyGame(game, unit);
        var sim    = m_lastGame = new SimGame(myGame, unit);

        m_lastTick = game.CurrentTick;
        DistService.CalcDists(sim);
        ShootService.Initialize(sim);
        foreach (var b in sim.Bullets)
        {
            b.CalcCollisionTime(sim);
        }

        foreach (var u in sim.Units)
        {
            u.WalkTarget = WalkService.FindWalkTarget(sim, u);
            u.AimTarget  = AimService.GetAimTarget(sim, u);
            u.Shoot      = ShootService.ShouldShoot(sim, u);
            if (u.Player.Id == unit.PlayerId)
            {
                u.IsMine = true;
            }
        }

        LogService.WriteLine("FIRETIMER: " + m_lastGame.Units.First(u => u.unit.Id == unit.Id).FireTimer);
        MCTSService.Search(sim);
        //foreach (var u in sim.Units) u.debug = true;
        MCTSService.DoOneRound(sim, true);
        //foreach (var u in sim.Units) u.debug = false;

        if (game.CurrentTick % 300 == 10)
        {
            Console.Error.WriteLine("Time: " + Const.GetTime + " Evals: " + Const.Evals + " Sims: " + Const.Sims);
        }
        var targetUnit = m_lastGame.Units.First(u => u.unit.Id == unit.Id);

        DistService.DrawPath(targetUnit.Position, targetUnit.WalkTarget);
        return(CreateAction(targetUnit, m_lastGame));
    }
Пример #27
0
        public bool VisitNode(Const node)
        {
            if (!Symbols.TryAddType(node))
            {
                //Consts do not have to be globally unique, but they do have to be unique within a scope
                if (((IObjectType)node.Outer).TypeDeclarations.Any(decl => decl != node && decl.Name.CaseInsensitiveEquals(node.Name)))
                {
                    return(Error($"A type named '{node.Name}' already exists in this {node.Outer.GetType().Name.ToLower()}!", node.StartPos, node.EndPos));
                }
            }


            node.Declaration = node;

            return(Success);
        }
Пример #28
0
        private DateTime ProcessDate(string xnya)
        {
            DateTime dt = DateTime.MinValue;

            try
            {
                string[] splitted = xnya.Replace("Найближча доступна дата для реєстрації є ", "").Split('.');
                string   s        = string.Format("{0}/{1}/{2}", splitted[0], Const.GetMonthAsInt(splitted[1]), splitted[2]);
                dt = DateTime.ParseExact(s, Const.DateFormat, CultureInfo.InvariantCulture);
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex.ToString());
            }
            return(dt);
        }
Пример #29
0
        private void AddAds()
        {
            Grid currentGrid = GetCurrentGrid();

            if (currentGrid != null && !(currentGrid.Children.Last() is AdmobControl))
            {
                AdmobControl admob = new AdmobControl()
                {
                    AdUnitId          = Const.GetRandomAds(),
                    VerticalOptions   = LayoutOptions.FillAndExpand,
                    HorizontalOptions = LayoutOptions.FillAndExpand,
                    Margin            = 0,
                };
                currentGrid.Children.Add(admob, 0, 1);
            }
        }
Пример #30
0
        /// <summary>
        /// 循环体内容
        /// </summary>
        public override void LoopContent()
        {
            if (!Config.Save2Sqlite)
            {
                return;
            }

            int sqlite_result = 0;

            try { sqlite_result = _dataService.InsertRadarDistance(Const.GnssInfo, Const.RadarInfo); }
            catch (Exception e) { Const.WriteConsoleLog("Sqlite保存失败:" + e.Message); }
            _taskLogsBuffer = new List <string>()
            {
                string.Format("Sqlite数据保存:{0}", sqlite_result)
            };
        }
Пример #31
0
    public void init(Cell cell)
    {
        this.cell = cell;

        cell.onDone += onDoneBuilding;
        GetComponent <Button>().onClick.AddListener(onClick);

        if (cell.cell_status != CellStatus.EMPTY)
        {
            txt_title.text  = Const.getBuildName(cell.type_build);
            img_icon.sprite = Const.getSpriteBuild(cell.type_build);
        }

        progress_bar.SetActive(cell.cell_status == CellStatus.IN_PROCESS);
        updateBar();
    }
Пример #32
0
        public static bool IsNodeVersionValid(long version, out string error)
        {
            error = null;

            string requiredNodeVersion = Const.MinBitcoindRequired();

            if (!string.IsNullOrEmpty(requiredNodeVersion))
            {
                long clientVersion = GetBitcoindClientVersion(requiredNodeVersion);
                if (version < clientVersion)
                {
                    error = $"Node version must be at least { requiredNodeVersion }.";
                }
            }
            return(error == null);
        }
Пример #33
0
 public void Use(UseData ud)
 {
     if (LevelManager.a.GetCurrentLevelSecurity() <= minSecurityLevel)
     {
         if (!broken)
         {
             ud.owner.GetComponent <PlayerReferenceManager>().playerCapsule.GetComponent <PlayerHealth>().HealingBed(amount);
             Const.sprint("Automatic healing process activated.", ud.owner);
             SFXSource.PlayOneShot(SFX);
         }
         else
         {
             Const.sprint("Healing bed is broken beyond repair", ud.owner);
         }
     }
 }
Пример #34
0
    public Object LoadMovie(string name)
    {
        obj = null;

        string path = Const.GetLocalFileUrl("Movie" + name);

        if (!File.Exists(path))
        {
            Debug.LogError(path + " is not exit!");
            return(obj);
        }

        StartCoroutine(DownAsset(path));

        return(obj);
    }
Пример #35
0
    /// <summary>
    /// 保存音效信息
    /// </summary>
    private void SaveAudioList()
    {
        StringBuilder sb = new StringBuilder();

        // TODO 后面要改成Json格式
        foreach (string key in audioDic.Keys)
        {
            string value;
            audioDic.TryGetValue(key, out value);
            sb.Append(key + "," + value + "\n");
        }

        File.WriteAllText(Const.GetLocalFileUrl(Const.Audio_Coinfig_Path), sb.ToString());

        AssetDatabase.Refresh();
    }
Пример #36
0
    void ExplodeOnDeath()
    {
        ExplosionForce ef    = GetComponent <ExplosionForce> ();
        DamageData     ddNPC = Const.SetNPCDamageData(index, Const.aiState.Attack3, gameObject);
        float          take  = Const.a.GetDamageTakeAmount(ddNPC);

        ddNPC.other  = gameObject;
        ddNPC.damage = take;
        //enemy.GetComponent<HealthManager>().TakeDamage(ddNPC); Handled by ExplodeInner
        if (ef != null)
        {
            ef.ExplodeInner((transform.position + viewVerticalOffset) + explosionOffset, attack3Force, attack3Radius, ddNPC);
        }
        healthManager.ObjectDeath(SFXAttack1);
        GetComponent <MeshRenderer> ().enabled = false;
    }
Пример #37
0
        public async Task LookupFriendshipAsync(IUserModel user)
        {
            var option = Const.GetDictionary();

            option.Add(Const.USER_ID, user.Id);
            var friendships = await tokens.Friendships.LookupAsync(option);

            if (friendships != null && friendships.Count != 0 &&
                friendships[0].Connections != null && friendships[0].Connections.Length != 0)
            {
                var connections = friendships[0].Connections.Select(c => c.ToLower()).ToList();

                user.IsFollowing  = connections.Contains(Const.FOLLOWING);
                user.IsFollowedBy = connections.Contains(Const.FOLLOWED_BY);
            }
        }
Пример #38
0
        void IPeer.on_message(Const <byte[]> buffer)
        {
            CPacket  msg         = new CPacket(buffer.Value, this);
            PROTOCOL protocol_id = (PROTOCOL)msg.pop_protocol_id();

            switch (protocol_id)
            {
            case PROTOCOL.CHAT_MSG_ACK:
            {
                get.a = msg.pop_string();
                //Console.WriteLine(string.Format("{0}", text));
                //MessageBox.Show(Program.get_text);
            }
            break;
            }
        }
Пример #39
0
 /// <summary>
 /// Serves as a hash function for a particular type.
 /// </summary>
 /// <returns>
 /// A hash code for the current <see cref="T:System.Object"/>.
 /// </returns>
 public override int GetHashCode()
 {
     unchecked
     {
         var hashCode = Type.GetHashCode();
         hashCode = (hashCode * 397) ^ (Id?.GetHashCode() ?? 0);
         hashCode = (hashCode * 397) ^ (Schema?.GetHashCode() ?? 0);
         hashCode = (hashCode * 397) ^ (Comment?.GetHashCode() ?? 0);
         hashCode = (hashCode * 397) ^ (Title?.GetHashCode() ?? 0);
         hashCode = (hashCode * 397) ^ (Description?.GetHashCode() ?? 0);
         hashCode = (hashCode * 397) ^ (Default?.GetHashCode() ?? 0);
         hashCode = (hashCode * 397) ^ MultipleOf.GetHashCode();
         hashCode = (hashCode * 397) ^ Maximum.GetHashCode();
         hashCode = (hashCode * 397) ^ ExclusiveMaximum.GetHashCode();
         hashCode = (hashCode * 397) ^ Minimum.GetHashCode();
         hashCode = (hashCode * 397) ^ ExclusiveMinimum.GetHashCode();
         hashCode = (hashCode * 397) ^ (MaxLength?.GetHashCode() ?? 0);
         hashCode = (hashCode * 397) ^ (MinLength?.GetHashCode() ?? 0);
         hashCode = (hashCode * 397) ^ (Pattern?.GetHashCode() ?? 0);
         hashCode = (hashCode * 397) ^ (AdditionalItems?.GetHashCode() ?? 0);
         hashCode = (hashCode * 397) ^ (Items?.GetHashCode() ?? 0);
         hashCode = (hashCode * 397) ^ (MaxItems?.GetHashCode() ?? 0);
         hashCode = (hashCode * 397) ^ (MinItems?.GetHashCode() ?? 0);
         hashCode = (hashCode * 397) ^ (UniqueItems?.GetHashCode() ?? 0);
         hashCode = (hashCode * 397) ^ (Contains?.GetHashCode() ?? 0);
         hashCode = (hashCode * 397) ^ (AdditionalProperties?.GetHashCode() ?? 0);
         hashCode = (hashCode * 397) ^ (Definitions?.GetCollectionHashCode().GetHashCode() ?? 0);
         hashCode = (hashCode * 397) ^ (Properties?.GetCollectionHashCode() ?? 0);
         hashCode = (hashCode * 397) ^ (PatternProperties?.GetCollectionHashCode() ?? 0);
         hashCode = (hashCode * 397) ^ (Dependencies?.GetCollectionHashCode() ?? 0);
         hashCode = (hashCode * 397) ^ (Const?.GetHashCode() ?? 0);
         hashCode = (hashCode * 397) ^ (Enum?.GetCollectionHashCode() ?? 0);
         hashCode = (hashCode * 397) ^ (Format?.GetHashCode() ?? 0);
         hashCode = (hashCode * 397) ^ (ContentMediaType?.GetHashCode() ?? 0);
         hashCode = (hashCode * 397) ^ (ContentEncoding?.GetHashCode() ?? 0);
         hashCode = (hashCode * 397) ^ (If?.GetHashCode() ?? 0);
         hashCode = (hashCode * 397) ^ (Then?.GetHashCode() ?? 0);
         hashCode = (hashCode * 397) ^ (Else?.GetHashCode() ?? 0);
         hashCode = (hashCode * 397) ^ (AllOf?.GetCollectionHashCode() ?? 0);
         hashCode = (hashCode * 397) ^ (AnyOf?.GetCollectionHashCode() ?? 0);
         hashCode = (hashCode * 397) ^ (OneOf?.GetCollectionHashCode() ?? 0);
         hashCode = (hashCode * 397) ^ (Not?.GetHashCode() ?? 0);
         hashCode = (hashCode * 397) ^ (Required?.GetCollectionHashCode() ?? 0);
         hashCode = (hashCode * 397) ^ (Examples?.GetCollectionHashCode() ?? 0);
         return(hashCode);
     }
 }
Пример #40
0
            private bool Init(IDBContext db, Incident incident)
            {
                this.errormessage = string.Empty;
                try
                {
                    this.incident   = incident;
                    this.groundblur = new GroundBlur(this.incident);
                    this.waterblur  = new WaterBlur(db, this.groundblur);

                    this.date = DateTime.Now;

                    if (!Const.isINFINITY(this.groundblur.timewatercomletion) && !Const.isINFINITY(this.groundblur.timemaxwaterconc))
                    {
                        this.datewatercompletion = (new DateTime(incident.date.Ticks)).AddSeconds(this.groundblur.timewatercomletion);
                        this.datemaxwaterconc    = (new DateTime(incident.date.Ticks)).AddSeconds(this.groundblur.timemaxwaterconc);
                    }
                    else
                    {
                        this.datewatercompletion = Const.DATE_INFINITY;
                        this.datemaxwaterconc    = Const.DATE_INFINITY;
                    }
                    if (!Const.isINFINITY(this.groundblur.timeconcentrationinsoil))
                    {
                        this.dateconcentrationinsoil = (new DateTime(incident.date.Ticks)).AddSeconds(this.groundblur.timeconcentrationinsoil);
                    }
                    else
                    {
                        this.dateconcentrationinsoil = Const.DATE_INFINITY;
                    }

                    foreach (WaterPollution p in this.waterblur.watepollutionlist)
                    {
                        if (!Const.isINFINITY(p.timemaxconcentration))
                        {
                            p.datemaxconcentration = this.incident.date.AddSeconds(p.timemaxconcentration);
                        }
                    }
                }
                catch (EGHDBException e)
                {
                    this.errormessage = e.ehgmessage;
                }



                return(true);
            }
        /*************************************************************
         * コンストラクタ
         *************************************************************/
        public Form_CostMng_FixedCostReg(Const.CATEGORY_TYPE category)
        {
            InitializeComponent();
            this.category = category;

            switch (category)
            {
                case Const.CATEGORY_TYPE.Budget:
                    this.Text = "固定費登録(予定)";
                    break;
                case Const.CATEGORY_TYPE.Actual:
                    this.Text = "固定費登録(実績)";
                    break;
            }

            monthPairText = new Dictionary<int, TextBox[]>()
            {
                { 4 , new TextBox[] { manufacturing_personnel_Apr, manufacturing_depreciation_Apr, manufacturing_rent_Apr, manufacturing_repair_Apr, manufacturing_stock_Apr, manufacturing_other_Apr, selling_personnel_Apr, selling_depreciation_Apr, selling_other_Apr, operating_expenses_Apr } }
              , { 5 , new TextBox[] { manufacturing_personnel_May, manufacturing_depreciation_May, manufacturing_rent_May, manufacturing_repair_May, manufacturing_stock_May, manufacturing_other_May, selling_personnel_May, selling_depreciation_May, selling_other_May, operating_expenses_May } }
              , { 6 , new TextBox[] { manufacturing_personnel_Jun, manufacturing_depreciation_Jun, manufacturing_rent_Jun, manufacturing_repair_Jun, manufacturing_stock_Jun, manufacturing_other_Jun, selling_personnel_Jun, selling_depreciation_Jun, selling_other_Jun, operating_expenses_Jun } }
              , { 7 , new TextBox[] { manufacturing_personnel_Jul, manufacturing_depreciation_Jul, manufacturing_rent_Jul, manufacturing_repair_Jul, manufacturing_stock_Jul, manufacturing_other_Jul, selling_personnel_Jul, selling_depreciation_Jul, selling_other_Jul, operating_expenses_Jul } }
              , { 8 , new TextBox[] { manufacturing_personnel_Aug, manufacturing_depreciation_Aug, manufacturing_rent_Aug, manufacturing_repair_Aug, manufacturing_stock_Aug, manufacturing_other_Aug, selling_personnel_Aug, selling_depreciation_Aug, selling_other_Aug, operating_expenses_Aug } }
              , { 9 , new TextBox[] { manufacturing_personnel_Sep, manufacturing_depreciation_Sep, manufacturing_rent_Sep, manufacturing_repair_Sep, manufacturing_stock_Sep, manufacturing_other_Sep, selling_personnel_Sep, selling_depreciation_Sep, selling_other_Sep, operating_expenses_Sep } }
              , { 10, new TextBox[] { manufacturing_personnel_Oct, manufacturing_depreciation_Oct, manufacturing_rent_Oct, manufacturing_repair_Oct, manufacturing_stock_Oct, manufacturing_other_Oct, selling_personnel_Oct, selling_depreciation_Oct, selling_other_Oct, operating_expenses_Oct } }
              , { 11, new TextBox[] { manufacturing_personnel_Nov, manufacturing_depreciation_Nov, manufacturing_rent_Nov, manufacturing_repair_Nov, manufacturing_stock_Nov, manufacturing_other_Nov, selling_personnel_Nov, selling_depreciation_Nov, selling_other_Nov, operating_expenses_Nov } }
              , { 12, new TextBox[] { manufacturing_personnel_Dec, manufacturing_depreciation_Dec, manufacturing_rent_Dec, manufacturing_repair_Dec, manufacturing_stock_Dec, manufacturing_other_Dec, selling_personnel_Dec, selling_depreciation_Dec, selling_other_Dec, operating_expenses_Dec } }
              , { 1 , new TextBox[] { manufacturing_personnel_Jan, manufacturing_depreciation_Jan, manufacturing_rent_Jan, manufacturing_repair_Jan, manufacturing_stock_Jan, manufacturing_other_Jan, selling_personnel_Jan, selling_depreciation_Jan, selling_other_Jan, operating_expenses_Jan } }
              , { 2 , new TextBox[] { manufacturing_personnel_Feb, manufacturing_depreciation_Feb, manufacturing_rent_Feb, manufacturing_repair_Feb, manufacturing_stock_Feb, manufacturing_other_Feb, selling_personnel_Feb, selling_depreciation_Feb, selling_other_Feb, operating_expenses_Feb } }
              , { 3 , new TextBox[] { manufacturing_personnel_Mar, manufacturing_depreciation_Mar, manufacturing_rent_Mar, manufacturing_repair_Mar, manufacturing_stock_Mar, manufacturing_other_Mar, selling_personnel_Mar, selling_depreciation_Mar, selling_other_Mar, operating_expenses_Mar } }
            };

            monthPairTotal = new Dictionary<int, Label>()
            {
                { 4 , total_Apr }
              , { 5 , total_May }
              , { 6 , total_Jun }
              , { 7 , total_Jul }
              , { 8 , total_Aug }
              , { 9 , total_Sep }
              , { 10, total_Oct }
              , { 11, total_Nov }
              , { 12, total_Dec }
              , { 1 , total_Jan }
              , { 2 , total_Feb }
              , { 3 , total_Mar }
            };
        }
        /*************************************************************
         * コンストラクタ
         *************************************************************/
        public Form_Common_SelectData(Const.SEARCH_TYPE type)
        {
            InitializeComponent();
            this.type = type;

            switch (type)
            {
                case Const.SEARCH_TYPE.Product:
                    this.Text = "商品検索";
                    break;
                case Const.SEARCH_TYPE.Supplier:
                    this.Text = "取引先検索";
                    break;
                case Const.SEARCH_TYPE.Material:
                    this.Text = "原材料検索";
                    break;
                case Const.SEARCH_TYPE.Packing:
                    this.Text = "資材検索";
                    break;
            }
        }
        /*************************************************************
         * 処理タイプの設定
         *************************************************************/
        public void setType(Const.STATUS_TYPE type)
        {
            this.type = type;

            switch (type)
            {
                case Const.STATUS_TYPE.Default:
                    this.Text = "実績登録(CSVファイル登録内容)";
                    description.Text = string.Concat("以下の内容で"
                        , targetMonth
                        , "月分に反映します。よろしければOKボタンを、キャンセルする場合は右上の「×」ボタンをクリックしてください。");
                    btnDecide.Visible = true;
                    btnClipboard.Visible = false;
                    break;
                case Const.STATUS_TYPE.Error:
                    this.Text = "実績登録(CSVファイル対応エラー内容)";
                    description.Text = "以下のデータが対応しませんでした。内容を確認してください。";
                    btnDecide.Visible = false;
                    btnClipboard.Visible = true;
                    break;
            }
        }
Пример #44
0
    private IEnumerable<KeyValuePair<MapPosition, TileController>> InitGrid(GridLayoutGroup grid, int numberOfRows, int numberOfColumns, Const.Team team, Action<MapPosition, bool> onTileClick)
    {
        grid.constraint = GridLayoutGroup.Constraint.FixedColumnCount;
        grid.constraintCount = numberOfColumns;
        for (int i = 0; i < numberOfRows; i++)
        {
            for (int j = 0; j < numberOfColumns; j++)
            {
                var mapPosition = new MapPosition(j, i, team);

                var tile = Instantiate(tilePrefab) as GameObject;
                tile.transform.SetParent(grid.transform);
                tile.transform.localScale = Vector3.one;
                tile.transform.localEulerAngles = Vector3.zero;
                tile.transform.localPosition = Vector3.zero;

                var tileController = tile.GetComponent<TileController>();
                tileController.Init(mapPosition, onTileClick);

                yield return new KeyValuePair<MapPosition, TileController>(mapPosition, tileController);
            }
        }
    }
Пример #45
0
 protected void setCategory(Const.CATEGORY_TYPE category)
 {
     this.category = category;
 }
Пример #46
0
    static int _CreateConst(IntPtr L)
    {
        int count = LuaDLL.lua_gettop(L);

        if (count == 0)
        {
            Const obj = new Const();
            LuaScriptMgr.PushObject(L, obj);
            return 1;
        }
        else
        {
            LuaDLL.luaL_error(L, "invalid arguments to method: Const.New");
        }

        return 0;
    }
Пример #47
0
    //处理战斗view的事件
    public IEnumerator FightViewTouchFn( Const.FIGHT_BTN_TYPE state)
    {
        //场上必须得有卡牌才能响应
        if (MineFightData.getInstance().usingCardsNumber() > 0 && FightController.getInstance().RightToPlay == FightController.RIGHTTOPLAY.MINE )
        {
            if (Const.FIGHT_BTN_TYPE.NO_OUT == state)
            {
                noOut();
                FightController.getInstance().RightToPlay = FightController.RIGHTTOPLAY.ENEMY;
            }
            else if (Const.FIGHT_BTN_TYPE.TIP == state)
            {
                noOut();
                if (currOutCardRule.Count == 0)
                {
                    currOutCardRule = getItemOutCardRule();
                }
                if (currOutCardRule.Count > 0)
                {
                    List<int> l = new List<int>();
                    l = currOutCardRule[0];
                    currOutCardRule.RemoveAt(0);
                    foreach (var pos in l)
                    {
                        cardToWaitPos(pos);
                    }
                }
            }
            //出击
            else if (Const.FIGHT_BTN_TYPE.ATK == state)
            {
                //此时是否有卡片可以出
                bool isHaveCardCanOut = false;
                for (int i = 1; i <= Const.FRIST_CARD_NUM; ++i)
                {
                    if (viewCardDic.ContainsKey(i) && viewCardDic[i].getCardState() == Card.CardState.waitFight)
                    {
                        isHaveCardCanOut = true;
                        FightController.getInstance().RightToPlay = FightController.RIGHTTOPLAY.MINEING;

                        viewCardDic[i].getObj().transform.SetAsLastSibling();
                        viewCardDic [i].getObj ().GetComponent<RectTransform> ().DOLocalMove (FightUIData.getInstance ().EnemyVec3 + new Vector3 (0, Screen.height * 0.2f, 0), 0.1f)
                            .SetEase(Ease.InBack).SetUpdate(true);
                        yield return new WaitForSeconds(0.3f);
                    }
                }
                if (isHaveCardCanOut) {
                    yield return new WaitForSeconds (0.6f);
                    FightController.getInstance ().RightToPlay = FightController.RIGHTTOPLAY.ENEMY;
                } else {
                    MsgPrompts.create ("请选择至少一张卡牌",Color.red);
                }
            }
        }
    }
Пример #48
0
 public static string GetTileKey(Const.Team team, int x, int y)
 {
     return string.Format("{0}_{1}_{2}_{3}", team, Const.TileKey, x, y);
 }
Пример #49
0
 public Spell(uint i, Const.WindowsVirtualKey kb) {
     this.ID = i;
     this.keybind = kb;
 }
Пример #50
0
 public Emitter ld(Const @const)
 {
     var ptx = new PtxConst(@const.Value);
     push(ptx);
     return this;
 }
Пример #51
0
 protected internal virtual void TraverseConst(Const @const) { @const.Unsupported(); }
Пример #52
0
 private void CreateCellWithDecimalValue(BattleCharacter character, Const.Stats stat)
 {
     this.CreateStatsCell(stat, character.GetStat(stat).ToString(), character.GetStatBuffState(stat));
 }
 protected internal override void TraverseConst(Const @const)
 {
     Dispatch(@const);
 }
Пример #54
0
 private void CreateCellWithPercentageValue(BattleCharacter character, Const.Stats stat)
 {
     this.CreateStatsCell(stat, string.Format("{0}%", character.GetStat(stat) * 100d), character.GetStatBuffState(stat));
 }
Пример #55
0
        /*************************************************************
         * 指定した取引先の荷造運賃を返却する(ブレンド品用)
         *************************************************************/
        protected decimal getPackingFareForBlend(CostAccountingEntities context, Const.CATEGORY_TYPE category
                                                , string productCode, string supplierCode, decimal volume)
        {
            var blend = from t_blend in context.ProductBlend
                        join t_product in context.Product
                          on new { t_blend.year, t_blend.code, t_blend.category } equals new { t_product.year, t_product.code, t_product.category }
                        where t_blend.year.Equals(Const.TARGET_YEAR)
                              && t_blend.product_code.Equals(productCode)
                              && t_blend.category.Equals((int)category)
                        orderby t_blend.no
                        select new { t_blend, t_product };

            decimal packingFareSum = decimal.Zero;
            foreach (var data in blend)
            {
                decimal packingFare = getPackingFare(context, category, data.t_blend.code, supplierCode, data.t_product.volume);
                packingFareSum += decimal.Multiply(packingFare, data.t_blend.blend_rate);
            }
            return packingFareSum;
        }
Пример #56
0
        /*************************************************************
         * 指定した取引先の荷造運賃を返却する
         *************************************************************/
        protected decimal getPackingFare(CostAccountingEntities context, Const.CATEGORY_TYPE category
                                        , string productCode, string supplierCode, decimal volume)
        {
            var packingFare = from t in context.ProductPackingFare
                              where t.year.Equals(Const.TARGET_YEAR)
                                 && t.product_code.Equals(productCode)
                                 && t.supplier_code.Equals(supplierCode)
                                 && t.category.Equals((int)category)
                              select t;

            decimal sumCostKgPerAmount = 0;
            DataTable fare = DataTableSupport.getInstance(category).fare;
            foreach (var data in packingFare)
            {
                decimal amount = decimal.Multiply(data.quantity, DataTableSupport.getPrice(fare, data.code));
                decimal kgPerAmount = (volume != decimal.Zero ? decimal.Divide(amount, volume) : decimal.Zero);
                sumCostKgPerAmount += kgPerAmount;
            }
            return sumCostKgPerAmount;
        }
Пример #57
0
 private void AddStatModifier(Const.Stats stat, double magnitude, Const.ModifierType bonusType)
 {
     this.StatsModifiers.Add(new StatModifier(stat, magnitude, bonusType));
 }
        /*************************************************************
         * コンボボックスなどの価格やレートの予算/実績を切り替える
         *************************************************************/
        private void changeRateValue(Const.CATEGORY_TYPE category)
        {
            // 原料費タブの設定
            initDgvComboBox(dgvMaterialCostName, DataTableSupport.getInstance(category).rowMaterial, "rowMaterialTable");

            // 製造経費-包装資材費タブの設定
            initDgvComboBox(dgvPackingName, DataTableSupport.getInstance(category).material, "materialTable");

            // 製造経費-設備費タブの設定
            initDgvComboBox(dgvMachineName, DataTableSupport.getInstance(category).machine, "machineTable");

            // 製造経費-荷造運賃タブの設定
            initDgvComboBox(dgvPackingFareName, DataTableSupport.getInstance(category).fare, "fareTable");

            // 労務費タブの設定
            wageRateM_direct.Text = Parameters.getInstance(category).wageM.ToString("N");
            wageRateF.Text = Parameters.getInstance(category).wageF.ToString("N");
            wageRateM_indirect.Text = Parameters.getInstance(category).wageIndirect.ToString("N");

            // 製造経費-水道光熱費タブの設定
            fuelAmountPerHourB.Text = Parameters.getInstance(category).utilitiesAD.ToString("N");
            fuelAmountPerHourA.Text = Parameters.getInstance(category).utilitiesFD.ToString("N");

            // 製造経費-その他経費タブの設定
            fuelAmountPerHourFD.Text = Parameters.getInstance(category).allocationFD.ToString("N");
            fuelAmountPerHourAD.Text = Parameters.getInstance(category).allocationAD.ToString("N");
            fuelAmountPerHourLabor.Text = Parameters.getInstance(category).allocationLabor.ToString("N");

            // 算出式を設定
            message1.Text = msgTemplate1.Replace("[x]", Parameters.getInstance(category).rateLoss.ToString());
            message2.Text = msgTemplate2.Replace("[x]", Parameters.getInstance(category).allocationSale.ToString());
            message3.Text = msgTemplate3.Replace("[x]", Parameters.getInstance(category).allocationMng.ToString())
                                        .Replace("[y]", Parameters.getInstance(category).allocationExt.ToString());
        }
Пример #59
0
 public virtual void loadFunctions(Rete engine)
 {
     Abs abs = new Abs();
     engine.declareFunction(abs);
     funcs.Add(abs);
     Acos acos = new Acos();
     engine.declareFunction(acos);
     funcs.Add(acos);
     Add add = new Add();
     engine.declareFunction(add);
     funcs.Add(add);
     Asin asin = new Asin();
     engine.declareFunction(asin);
     funcs.Add(asin);
     Atan atan = new Atan();
     engine.declareFunction(atan);
     funcs.Add(atan);
     Ceil ceil = new Ceil();
     engine.declareFunction(ceil);
     funcs.Add(ceil);
     Const cnst = new Const();
     engine.declareFunction(cnst);
     funcs.Add(cnst);
     Cos cos = new Cos();
     engine.declareFunction(cos);
     funcs.Add(cos);
     Degrees degrees = new Degrees();
     engine.declareFunction(degrees);
     funcs.Add(degrees);
     Divide div = new Divide();
     engine.declareFunction(div);
     funcs.Add(div);
     EqFunction eqf = new EqFunction();
     engine.declareFunction(eqf);
     funcs.Add(eqf);
     Evenp evenp = new Evenp();
     engine.declareFunction(evenp);
     funcs.Add(evenp);
     Exp exp = new Exp();
     engine.declareFunction(exp);
     funcs.Add(exp);
     Floor floor = new Floor();
     engine.declareFunction(floor);
     funcs.Add(floor);
     Greater gr = new Greater();
     engine.declareFunction(gr);
     funcs.Add(gr);
     GreaterOrEqual gre = new GreaterOrEqual();
     engine.declareFunction(gre);
     funcs.Add(gre);
     Less le = new Less();
     engine.declareFunction(le);
     funcs.Add(le);
     LessOrEqual leoe = new LessOrEqual();
     engine.declareFunction(leoe);
     funcs.Add(leoe);
     Log log = new Log();
     engine.declareFunction(log);
     funcs.Add(log);
     Max max = new Max();
     engine.declareFunction(max);
     funcs.Add(max);
     Min min = new Min();
     engine.declareFunction(min);
     funcs.Add(min);
     Multiply mul = new Multiply();
     engine.declareFunction(mul);
     funcs.Add(mul);
     NeqFunction neq = new NeqFunction();
     engine.declareFunction(neq);
     funcs.Add(neq);
     Oddp oddp = new Oddp();
     engine.declareFunction(oddp);
     funcs.Add(oddp);
     Pow pow = new Pow();
     engine.declareFunction(pow);
     funcs.Add(pow);
     Radians radians = new Radians();
     engine.declareFunction(radians);
     funcs.Add(radians);
     Random random = new Random();
     engine.declareFunction(random);
     funcs.Add(random);
     Rint rint = new Rint();
     engine.declareFunction(rint);
     funcs.Add(rint);
     Round round = new Round();
     engine.declareFunction(round);
     funcs.Add(round);
     Sin sin = new Sin();
     engine.declareFunction(sin);
     funcs.Add(sin);
     Sqrt sqrt = new Sqrt();
     engine.declareFunction(sqrt);
     funcs.Add(sqrt);
     Subtract sub = new Subtract();
     engine.declareFunction(sub);
     funcs.Add(sub);
     Tan tan = new Tan();
     engine.declareFunction(tan);
     funcs.Add(tan);
     // now we Add the functions under alias
     engine.declareFunction("+", add);
     engine.declareFunction("-", sub);
     engine.declareFunction("*", mul);
     engine.declareFunction("/", div);
     engine.declareFunction("**", pow);
     engine.declareFunction(">", gr);
     engine.declareFunction(">=", gre);
     engine.declareFunction("<", le);
     engine.declareFunction("<=", leoe);
 }
 /*************************************************************
  * 商品検索/取引先検索の検索データを設定する
  *************************************************************/
 private void setSelectData(Const.SEARCH_TYPE type)
 {
     Form_Common_SelectData form = new Form_Common_SelectData(type);
     form.ShowDialog();
     if (form.DialogResult == DialogResult.OK)
     {
         string code = (string)form.dataGridView.SelectedRows[0].Cells[0].Value;
         string name = (string)form.dataGridView.SelectedRows[0].Cells[1].Value;
         string note = (string)form.dataGridView.SelectedRows[0].Cells[2].Value;
         string unit = (string)form.dataGridView.SelectedRows[0].Cells[3].Value;
         switch (type)
         {
             case Const.SEARCH_TYPE.Product:
                 productCode.Text = code;
                 productName.Text = name;
                 saleUnit.Text = unit;
                 break;
             case Const.SEARCH_TYPE.Supplier:
                 suppllierCode.Text = code;
                 suppllierName.Text = name;
                 break;
         }
     }
     form.Dispose();
 }