Пример #1
0
        public void BtnOk_Click(object sender, EventArgs e)//当点击确定的时候,页面上的数据,要保存在caseInfo中,然后将caseInfo写回到数据库中
        {
            Console.WriteLine("编辑案件:");
            this.Case.Path                       = Program.m_mainform.g_workPath;
            this.Case.CaseName                   = textBox1.Text;
            this.Case.CaseSerialNum              = textBox2.Text;
            this.Case.CaseType                   = comboBox1.Text;
            this.Case.Collecter                  = textBox3.Text;
            this.Case.CollecterNum               = textBox4.Text;
            this.Case.CollecterDepartMent        = comboBox2.Text;
            this.Case.InspectionPersonName       = textBox5.Text;
            this.Case.InspectionPersonDepartMent = textBox6.Text;
            this.Case.OrganizationCode           = textBox7.Text;
            this.Case.Note                       = textBox8.Text;
            //向数据库中写回更改之后的数据
            AppConfig ac = AppConfig.getAppConfig();

            using (CaseContext caseContext = new CaseContext())
            {
                var caseInfo = this.Case;
                var entry    = caseContext.Entry(caseInfo);
                caseContext.Set <Case>().Attach(entry.Entity);
                entry.State = System.Data.Entity.EntityState.Modified;
                caseContext.SaveChanges();
            }
            Program.m_mainform.AddNewGjalAj();

            MessageBox.Show("编辑案件成功!");

            this.Close();
        }
Пример #2
0
        private static void RunStatement(ref CaseContext ctx, ForStatement stmt)
        {
            var from = GetValue(ref ctx, stmt.From);
            var to   = GetValue(ref ctx, stmt.To);

            for (ulong i = from.Number; i < to.Number; i++)
            {
                ctx.Set(stmt.VarName, new BitsValue(i, to.Length));
                RunStatements(ref ctx, stmt.Body);
            }
        }
Пример #3
0
        private void button1_Click(object sender, EventArgs e)
        {
            this.Proof.ProofName      = textBox1.Text;
            this.Proof.ProofSerialNum = textBox2.Text;
            this.Proof.PhoneNum       = textBox6.Text;
            this.Proof.phoneNum2      = textBox3.Text;
            this.Proof.Holder         = textBox4.Text;
            this.Proof.ProofType      = comboBox2.Text;
            this.Proof.note           = textBox8.Text;
            //向数据库中写回更改之后的数据
            AppConfig ac = AppConfig.getAppConfig();

            using (CaseContext caseContext = new CaseContext())
            {
                var proofInfo = this.Proof;
                var entry     = caseContext.Entry(proofInfo);
                caseContext.Set <Proof>().Attach(entry.Entity);
                entry.State = System.Data.Entity.EntityState.Modified;
                caseContext.SaveChanges();
            }
            Program.m_mainform.AddNewGjalAj();
            MessageBox.Show("编辑证据成功!");
            this.Close();
        }
Пример #4
0
        private static BitsValue DoAssignment(ref CaseContext ctx, OperatorExpression op)
        {
            if (!op.Left.IsWriteable)
            {
                throw new LogicEngineException("Expected a writeable expression", op);
            }

            if (!op.Right.IsReadable)
            {
                throw new LogicEngineException("Expected a readable expression", op);
            }

            var lhs = op.Left;

            var  value = GetValue(ref ctx, op.Right);
            int  start, end;
            bool isRanged = false;

            if (lhs is IndexerExpression indexer)
            {
                GetRange(ref ctx, indexer, value.Length, out start, out end);
                lhs      = indexer.Operand;
                isRanged = true;
            }
            else
            {
                start = 0;
                end   = GetLength(ctx.Machine, lhs);
            }

            if (end == 0)
            {
                end = start + value.Length;
            }

            if (value.Length > end - start)
            {
                throw new LogicEngineException("Value doesn't fit in range", op);
            }

            Span <bool> bits = stackalloc bool[value.Length];

            value.FillBits(bits);

            if (lhs is SlotExpression slot)
            {
                switch (slot.Slot)
                {
                case Slots.Out:
                    if (end > ctx.Machine.OutputCount)
                    {
                        throw new LogicEngineException("Range out of bounds for outputs", op);
                    }

                    ctx.Machine.SetOutputs(start, value);
                    break;

                case Slots.Memory:
                    if (end > ctx.Machine.Memory.Capacity)
                    {
                        throw new LogicEngineException("Range out of bounds for memory", op);
                    }

                    //ctx.Machine.Memory.Write(start, bits);
                    break;

                default:
                    throw new LogicEngineException("Invalid slot on expression", op);
                }
            }
            else if (lhs is VariableAccessExpression var)
            {
                if (!isRanged)
                {
                    ctx.Set(var.Name, value);
                }
                else
                {
                    //var val = ctx.Get(var.Name, var);
                    throw new LogicEngineException("Cannot index variable", var);
                }
            }

            return(value);
        }