コード例 #1
0
        private List <Thing> TransactorThings(Transactor trans)
        {
            List <Thing> result;

            if (trans == Transactor.Colony)
            {
                result = this.thingsColony;
            }
            else
            {
                result = this.thingsTrader;
            }
            return(result);
        }
コード例 #2
0
        public int CountPostDealFor(Transactor trans)
        {
            int result;

            if (trans == Transactor.Colony)
            {
                result = this.CountHeldBy(trans) + base.CountToTransferToSource;
            }
            else
            {
                result = this.CountHeldBy(trans) + base.CountToTransferToDestination;
            }
            return(result);
        }
コード例 #3
0
        public async Task <IActionResult> OnPostAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            Transactor = await _context.Transactors.FindAsync(id);

            if (Transactor != null)
            {
                _context.Transactors.Remove(Transactor);

                try
                {
                    await _context.SaveChangesAsync();
                }
                catch (Exception ex)
                {
                    if (ex.GetBaseException().GetType() == typeof(SqlException))
                    {
                        Int32 ErrorCode = ((SqlException)ex.InnerException).Number;
                        switch (ErrorCode)
                        {
                        case 2627:      // Unique constraint error
                            break;

                        case 547:       // Constraint check violation
                            _toastNotification.AddErrorToastMessage("Ο συν/νος έχει κινήσεις και δεν μπορεί να διαγραφεί");

                            break;

                        case 2601:      // Duplicated key row error
                            break;

                        default:
                            break;
                        }
                    }
                    else
                    {
                        // handle normal exception
                        throw;
                    }
                }
            }

            return(RedirectToPage("./Index"));
        }
コード例 #4
0
        public async Task <IActionResult> OnGetAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            Transactor = await _context.Transactors
                         .Include(t => t.TransactorType).FirstOrDefaultAsync(m => m.Id == id);

            if (Transactor == null)
            {
                return(NotFound());
            }
            return(Page());
        }
コード例 #5
0
ファイル: Methods.cs プロジェクト: jeremybris/RimBank
        public static void UpdateCurrencyCount(TradeDeal This, Pair <int, int> currencyfmt)
        {
            This.CurrencyTradeable.ForceTo(currencyfmt.Second);
            int        num        = Math.Abs(currencyfmt.First);
            Transactor transactor = (currencyfmt.First >= 0) ? Transactor.Trader : Transactor.Colony;

            for (int num2 = cacheNotes.Count - 1; num2 > -1; num2--)
            {
                int num3 = cacheNotes[num2].CountHeldBy(transactor);
                if (debug)
                {
                    Utility.DebugprintfUpdateCurrencyCount(num, num3, transactor);
                }
                if (num3 != 0)
                {
                    if (num < num3)
                    {
                        num3 = num;
                        num  = 0;
                    }
                    else
                    {
                        num -= num3;
                    }
                    if (transactor == Transactor.Colony)
                    {
                        num3 = -num3;
                    }
                    if (debug)
                    {
                        Utility.DebugprintfUpdateCurrencyCount(num, num3, transactor);
                    }
                    cacheNotes[num2].ForceTo(num3);
                    if (num == 0)
                    {
                        break;
                    }
                }
            }
            if (debug)
            {
                Utility.DebugOutputTradeables((List <Tradeable>)tradeables.GetValue(This));
            }
        }
コード例 #6
0
        private void AddToTradeables(Thing t, Transactor trans)
        {
            Tradeable tradeable = TransferableUtility.TradeableMatching(t, this.tradeables);

            if (tradeable == null)
            {
                Pawn pawn = t as Pawn;
                if (pawn != null)
                {
                    tradeable = new Tradeable_Pawn();
                }
                else
                {
                    tradeable = new Tradeable();
                }
                this.tradeables.Add(tradeable);
            }
            tradeable.AddThing(t, trans);
        }
コード例 #7
0
        public async Task <IActionResult> PostTransactor([FromBody] Transactor transactor)
        {
            if (transactor.TransactorType is null)
            {
                var tr = await _context.TransactorTypes.SingleOrDefaultAsync(p => p.Code == "SYS.DTRANSACTOR");

                if (tr != null)
                {
                    transactor.TransactorTypeId = tr.Id;
                }
            }
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            _context.Transactors.Add(transactor);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetTransactor", new { id = transactor.Id }, transactor));
        }
コード例 #8
0
ファイル: Trading.cs プロジェクト: rwmt/Multiplayer
        private void CheckReassign(Tradeable tradeable, Transactor side)
        {
            List <Thing> things = side == Transactor.Colony ? tradeable.thingsColony : tradeable.thingsTrader;

            for (int j = things.Count - 1; j >= 1; j--)
            {
                Thing             thing = things[j];
                TransferAsOneMode mode  = tradeable.TraderWillTrade ? TransferAsOneMode.Normal : TransferAsOneMode.InactiveTradeable;

                if (recacheThings.Contains(thing))
                {
                    if (!TransferableUtility.TransferAsOne(tradeable.AnyThing, thing, mode))
                    {
                        things.RemoveAt(j);
                    }
                    else
                    {
                        AddToTradeables(thing, side);
                    }
                }
            }
        }
コード例 #9
0
        public static void AddTransactorToXml(string path, string name, string since, string dueDate, string phone, string email, decimal amount, string currencyAbbreviation, string facebook, string transactorType)
        {
            if (path == null)
            {
                throw new NullReferenceException(ErrorMessage.PathCannotBeNull);
            }
            if (!File.Exists(path))
            {
                throw new InvalidOperationException(ErrorMessage.FileDoesntExist);
            }

            Transactor transactor = new Transactor(name, since, dueDate, phone, email, facebook, amount, currencyAbbreviation, transactorType);
            int        idCount    = int.Parse(File.ReadAllText(IdCounterFilePath));

            transactor.Id = idCount++;
            File.WriteAllText(IdCounterFilePath, idCount.ToString());

            XDocument xmlDocument = XDocument.Load(TransactorsFilePath);
            IEnumerable <XElement> transactorsWithType = xmlDocument
                                                         .Element(XmlRoot)
                                                         .Elements(XmlElement)
                                                         .Where(x => x.Element("TransactorType").Value == transactorType);

            transactor.No = transactorsWithType.Count() + 1;

            xmlDocument.Element(XmlRoot)
            .Add(new XElement(XmlElement, new XAttribute("id", transactor.Id), new XAttribute("no", transactor.No),
                              new XElement("Name", name),
                              new XElement("Since", since),
                              new XElement("DueDate", dueDate),
                              new XElement("PhoneNumber", phone),
                              new XElement("Email", email),
                              new XElement("Facebook", facebook),
                              new XElement("Amount", amount.ToString("f2")),
                              new XElement("CurrencyAbbreviation", currencyAbbreviation),
                              new XElement("TransactorType", transactorType)));

            xmlDocument.Save(TransactorsFilePath, SaveOptions.DisableFormatting);
        }
コード例 #10
0
        private void button2_Click(object sender, EventArgs e)
        {
            if (nameTxt.Text == "")
            {
                nameTxt.BackColor = Color.Red;
                return;
            }
            if (contactTxt.Text == "")
            {
                contactTxt.BackColor = Color.Red;
                return;
            }
            if (typeCbx.Text == "")
            {
                typeCbx.BackColor = Color.Red;
                return;
            }

            string id = Guid.NewGuid().ToString();

            MemoryStream stream    = ImageToStream(imgCapture.Image, System.Drawing.Imaging.ImageFormat.Jpeg);
            string       fullimage = ImageToBase64(stream);

            _transactor = new Transactor(id, noTxt.Text, contactTxt.Text, nameTxt.Text, emailTxt.Text, addressTxt.Text, fullimage, DateTime.Now.ToString("dd-MM-yyyy H:mm:ss"), typeCbx.Text, Helper.orgID);

            if (DBConnect.Insert(_transactor) != "")
            {
                //string query = "insert into patient (id, patientNo,contact,surname,lastname,email,dob,nationality,address,kin,kincontact,gender,created) values ('"+ id + "', '"+ patientNoTxt.Text + "', '"+ contactTxt.Text + "', '" + surnameTxt.Text + "', '" + lastnameTxt.Text + "', '" + emailTxt.Text + "', '" +Convert.ToDateTime(dobdateTimePicker1.Text).ToString("dd-MM-yyyy") + "', '" + nationalityTxt.Text + "', '" + addressTxt.Text + "', '" + kinTxt.Text + "','" + kincontactTxt.Text + "', '" + genderCbx.Text + "','"+DateTime.Now.ToString("dd-MM-yyyy H:m:s")+"');";
                // Global._patients.Add(_patient);
                MessageBox.Show("Information Saved");
                this.DialogResult = DialogResult.OK;
                this.Dispose();
            }
            else
            {
            }
        }
コード例 #11
0
        private void button3_Click(object sender, EventArgs e)
        {
            if (nameTxt.Text == "")
            {
                nameTxt.BackColor = Color.Red;
                return;
            }

            if (saleTxt.Text == "")
            {
                saleTxt.BackColor = Color.Red;
                return;
            }
            if (qtyTxt.Text == "")
            {
                qtyTxt.BackColor = Color.Red;
                return;
            }
            if (purchaseTxt.Text == "")
            {
                purchaseTxt.BackColor = Color.Red;
                return;
            }
            if (!String.IsNullOrEmpty(ItemID))
            {
                if (Global._items.Where(t => t.Id.Contains(ItemID)).ToList().Count() < 1)
                {
                    MemoryStream stream    = ImageToStream(imgCapture.Image, System.Drawing.Imaging.ImageFormat.Jpeg);
                    string       fullimage = ImageToBase64(stream);
                    _item = new Item(ItemID, nameTxt.Text, codeTxt.Text, descriptionTxt.Text, mannufacturerTxt.Text, ctryTxt.Text, batchTxt.Text, purchaseTxt.Text, saleTxt.Text, compositionTxt.Text, Convert.ToDateTime(expireDate.Text).ToString("dd-MM-yyyy"), categoryCbx.Text, packageCbx.Text, barcodeTxt.Text, fullimage, DateTime.Now.ToString("dd-MM-yyyy H:mm:ss"), departmentCbx.Text, Convert.ToDateTime(manufactureDate.Text).ToString("dd-MM-yyyy"), genericTxt.Text, strengthTxt.Text, Helper.orgID);

                    if (DBConnect.Insert(_item) != "")
                    {
                        if (Global._stocks.Where(t => t.ItemID.Contains(ItemID)).Count() > 0)
                        {
                            double value = 0;
                            string qty   = Global._stocks.First(t => t.ItemID.Contains(ItemID)).Quantity;
                            value = Convert.ToDouble(qty) + Convert.ToDouble(qtyTxt.Text);

                            string itemID = Global._stocks.First(t => t.ItemID.Contains(ItemID)).ItemID;
                            string SQL    = "UPDATE stock SET qty = '" + value + "', WHERE itemID = '" + itemID + "'";
                            DBConnect.Execute(SQL);
                        }
                        else
                        {
                            double totalQty = Convert.ToDouble(purchaseTxt.Text) * Convert.ToDouble(qtyTxt.Text);
                            string id       = Guid.NewGuid().ToString();
                            _stock = new Stock(id, ItemID, qtyTxt.Text, descriptionTxt.Text, DateTime.Now.ToString("dd-MM-yyyy H:mm:ss"), saleTxt.Text, purchaseTxt.Text, purchaseTxt.Text, purchaseTxt.Text, totalQty.ToString(), Helper.orgID);
                            DBConnect.Insert(_stock);
                            Global._stocks.Add(_stock);
                        }

                        if (Global._transactors.Where(t => t.Id.Contains(SupplierID)).Count() < 0)
                        {
                            MemoryStream streams    = ImageToStream(pictureBox1.Image, System.Drawing.Imaging.ImageFormat.Jpeg);
                            string       fullimages = ImageToBase64(streams);
                            string       id         = Guid.NewGuid().ToString();
                            _transactor = new Transactor(id, supplierNoTxt.Text, contactTxt.Text, supplierTxt.Text, emailTxt.Text, addressTxt.Text, fullimages, DateTime.Now.ToString("dd-MM-yyyy H:mm:ss"), "Supplier", Helper.orgID);
                            DBConnect.Insert(_transactor);
                            SupplierID = id;
                        }


                        if (!String.IsNullOrEmpty(noTxt.Text) && !String.IsNullOrEmpty(SupplierID))
                        {
                            string id = Guid.NewGuid().ToString();
                            _bill = new Bill(id, noTxt.Text, SupplierID, remarksTxt.Text, purchaseDate.Text, purchaseTxt.Text, balanceTxt.Text, methodCbx.Text, paidCbx.Text, DateTime.Now.ToString("dd-MM-yyyy H:mm:ss"), departmentCbx.Text, Convert.ToDateTime(dueDate.Text).ToString("dd-MM-yyyy"), chqTxt.Text, bankTxt.Text, "Purchase", "", "", Helper.orgID);
                            DBConnect.Insert(_bill);
                            string id2 = Guid.NewGuid().ToString();
                            _transaction = new Transaction(id2, noTxt.Text, ItemID, qtyTxt.Text, Convert.ToDateTime(purchaseDate.Text).ToString("dd-MM-yyyy"), purchaseTxt.Text, "Purchase", DateTime.Now.ToString("dd-MM-yyyy H:mm:ss"), Helper.orgID);
                            DBConnect.Insert(_transaction);
                        }

                        if (Global._dosages.Where(t => t.ItemID.Contains(ItemID)).Count() < 0)
                        {
                            string id = Guid.NewGuid().ToString();
                            _dosage = new Dosage(id, ItemID, doseTxt.Text, prescriptionTxt.Text, dosageQtyTxt.Text, minTxt.Text, maxTxt.Text, DateTime.Now.ToString("dd-MM-yyyy H:mm:ss"), Helper.orgID);
                            DBConnect.Insert(_dosage);
                        }

                        Global._items.Add(_item);
                        MessageBox.Show("Information Saved");
                        this.DialogResult = DialogResult.OK;
                        this.Dispose();
                    }
                    else
                    {
                        MessageBox.Show("No valid Item identification ");
                    }
                }
            }
        }
コード例 #12
0
 public static T ScalarWhere <T>(string condition) where T : Model, new()
 {
     return(Transactor.GetScalarWhere <T>(condition));
 }
コード例 #13
0
ファイル: Utility.cs プロジェクト: jeremybris/RimBank
 public static void DebugprintfUpdateCurrencyCount(int num, int j, Transactor target)
 {
     Log.Message("num=" + num + ",target=" + target + ",j=" + j);
 }
コード例 #14
0
 public virtual void SetWhereID(int id)
 {
     Transactor.SetScalarWhere(this, string.Format(Resources.WhereID, id));
 }
コード例 #15
0
 public virtual void SetWhere(string condition)
 {
     Transactor.SetScalarWhere(this, condition);
 }
コード例 #16
0
 public virtual void Drop()
 {
     Transactor.Drop(GetType());
 }
コード例 #17
0
 public static List <T> StoredProcedure <T>(string name, List <Parameter> parameters) where T : Model, new()
 {
     return(Transactor.StoredProcedure <T>(name, parameters));
 }
コード例 #18
0
 public static void DeleteWhere <T>(string condition) where T : Model, new()
 {
     Transactor.DeleteWhere <T>(condition);
 }
コード例 #19
0
 public static List <T> GetWhere <T>(string condition) where T : Model, new()
 {
     return(Transactor.GetWhere <T>(condition));
 }
コード例 #20
0
        public static void MakeTests()
        {
            const int iterations = 100;

            // Drops the table.
            tests.Add(new Test("Drop Model Table", delegate
            {
                Transactor.Drop(typeof(Thing));

                return(true);
            }));

            // Inserts Models.
            tests.Add(new Test("Insert Model", delegate
            {
                Thing thing = new Thing();

                for (int x = 1; x <= iterations; x++)
                {
                    thing      = new Thing();
                    thing.Name = "Not Ray" + " " + x;
                    thing.Save();
                }

                return(thing.ID == iterations);
            }));

            // Updates Models.
            tests.Add(new Test("Update Model", delegate
            {
                Thing thing = new Thing();

                for (int x = 1; x <= iterations; x++)
                {
                    thing      = new Thing(x);
                    thing.Name = "Ray" + " " + x;
                    thing.Save();
                }

                return(thing.ID == iterations);
            }));

            // Sets an object using an ID.
            tests.Add(new Test("Set Where ID", delegate
            {
                Thing thing = new Thing();

                for (int x = 1; x <= iterations; x++)
                {
                    thing      = new Thing();
                    thing.Name = "Not Joe";
                    thing.SetWhereID(x);
                }

                return(thing.Name.Equals("Ray" + " " + iterations));
            }));

            // Sets an object using a constructor argument.
            tests.Add(new Test("Constructor Set Where ID", delegate
            {
                Thing thing = new Thing(1);

                for (int x = 1; x <= iterations; x++)
                {
                    thing = new Thing(x);
                }

                return(thing.Name.Equals("Ray" + " " + iterations));
            }));

            // Sets an object using a developer-defined query condition.
            tests.Add(new Test("Set Where", delegate
            {
                Thing thing = new Thing();

                for (int x = 1; x <= iterations; x++)
                {
                    thing.SetWhere("Name = 'Ray" + " " + iterations + "'");
                }

                return(thing.ID == iterations);
            }));

            // Tests the reading and writing of properties with very long names.
            tests.Add(new Test("Scalar Long Identifier", delegate
            {
                Thing thing = new Thing(1);
                thing.Name  = "Ray";
                thing.PropertyNameThatIsLongerThanThirtyCharacters = "This";
                thing.Save();

                thing.SetWhereID(1);

                return(thing.PropertyNameThatIsLongerThanThirtyCharacters.Equals("This"));
            }));

            // Tests the correct values are assigned to a property returned by a static call.
            tests.Add(new Test("Static Scalar Where ID Value", delegate
            {
                Thing thing = new Thing();

                for (int x = 1; x <= iterations; x++)
                {
                    thing = Thing.ScalarWhereID <Thing>(x);
                }

                return(thing.ID == iterations);
            }));

            // Tests the instance type returned by a static call.
            tests.Add(new Test("Static Scalar Where ID Type", delegate
            {
                Thing thing = Thing.ScalarWhereID <Thing>(1);

                return(thing.GetType().Equals(typeof(Thing)));
            }));

            // Gets an instance statically with query conditions.
            tests.Add(new Test("Static Scalar Where", delegate
            {
                Thing thing = new Thing();

                for (int x = 1; x <= iterations; x++)
                {
                    thing = Thing.ScalarWhere <Thing>("Name = 'Ray" + " " + iterations + "'");
                }

                return(thing.ID == iterations);
            }));

            // Gets a collection of the static caller's type with query conditions.
            tests.Add(new Test("Static Get Collection", delegate
            {
                return(Thing.GetWhere <Thing>("Name LIKE '%Ray%'").Count == iterations);
            }));

            // Gets an instance statically with a stored procedure.
            tests.Add(new Test("Procedure Scalar", delegate
            {
                List <Thing> list = new List <Thing>();

                for (int x = 1; x <= iterations; x++)
                {
                    List <Parameter> parameters = new List <Parameter>();
                    parameters.Add(new Parameter("p_id", typeof(int), x));

                    List <Thing> tmp = Thing.StoredProcedure <Thing>("THING_PROCEDURE", parameters);

                    if (tmp.Count > 0)
                    {
                        list.AddRange(tmp);
                    }
                }

                return(list.Count == iterations);
            }));

            // Gets a list of the static caller's type from an implicit cursor returning stored procedure.
            tests.Add(new Test("Procedure Get Collection", delegate
            {
                List <Parameter> parameters = new List <Parameter>();

                return(Thing.StoredProcedure <Thing>("THING_PROCEDURE", parameters).Count == iterations);
            }));

            // Deletes records according to conditions.
            tests.Add(new Test("Static Delete Where", delegate
            {
                Thing.DeleteWhere <Thing>("Name LIKE '%Ray%'");

                return(Transactor.GetGeneric("count(*)", "thing")[0][0].ToString().Equals("0"));
            }));
        }
コード例 #21
0
ファイル: Utility.cs プロジェクト: jeremybris/RimBank
 internal static int GetNotesBalanceAvaliable(Transactor trans)
 {
     return(GetNotesCountAvaliable(trans) * 1000);
 }
コード例 #22
0
        private void DoTransactAlarm()
        {
            try
            {
                TransactTime = DateTime.Now;
                IsTransact   = true;

                if (Transactor.Equals("") && SystemContext.MonitorSystem.LoginUser != null)
                {
                    Transactor = SystemContext.MonitorSystem.LoginUser.Name;
                }

                if (TransactText.Equals(""))
                {
                    TransactText = "×Ô¶¯´¦Àí";
                }

                if (mMonitor.Config.AutoSaveAlarmInfo)
                {
                    SaveAlarmInfo();
                }

                mMonitor.AlarmManager.RemoveAlarm(this);

                bool isExist = mMonitor.AlarmManager.Count > 0;

                CLocalSystem.WriteDebugLog(string.Format("CMonitorAlarm.DoTransactAlarm MonitorName={0} AlarmCount={1}", mMonitor.Name, mMonitor.AlarmManager.Count));

                if (CLocalSystem.MainForm != null)
                {
                    MethodInvoker form_invoker = delegate
                    {
                        if (OnTransactAlarm != null)
                        {
                            OnTransactAlarm(this, isExist);
                        }

                        if (IsTransact)
                        {
                            StartTransactAction();
                        }
                    };
                    CLocalSystem.MainForm.Invoke(form_invoker);
                }
                else
                {
                    if (OnTransactAlarm != null)
                    {
                        OnTransactAlarm(this, isExist);
                    }

                    if (IsTransact)
                    {
                        StartTransactAction();
                    }
                }
                //OnRecordStateChanged -= new RecordStateChanged(DoRecordStateChanged);
            }
            catch (Exception e)
            {
                CLocalSystem.WriteErrorLog(string.Format("CMonitorAlarm.DoTransactAlarm Exception: {0}", e));
            }
        }
コード例 #23
0
 // Virtual members.
 public virtual void Save()
 {
     Transactor.Persist(this);
 }
コード例 #24
0
 // Static members.
 public static T ScalarWhereID <T>(int id) where T : Model, new()
 {
     return(Transactor.GetScalarWhere <T>(string.Format(Resources.WhereID, id)));
 }