Exemplo n.º 1
0
        public Form1()
        {
            m_AddNewItem  = new AddNewItem(this.AddItem);
            m_InsertItem  = new InsertItem(this.AddOrInsertItem);
            m_ChangedItem = new ChangedItem(this.ChangeItem);
            m_DeletedItem = new DeletedItem(this.DeleteItem);

            InitializeComponent();
            _IpHlpAPI           = new IpHlpApidotnet.IPHelper();
            conns.ItemAdded    += new TCPUDPConnections.ItemAddedEvent(conns_ItemAdded);
            conns.ItemInserted += new TCPUDPConnections.ItemInsertedEvent(conns_ItemInserted);
            conns.ItemChanged  += new TCPUDPConnections.ItemChangedEvent(conns_ItemChanged);
            conns.ItemDeleted  += new TCPUDPConnections.ItemDeletedEvent(conns_ItemDeleted);
            RefreshLower();

            //hack to initially try to reduce the memory footprint of the app (admin only)
            try
            {
                Process loProcess = Process.GetCurrentProcess();
                loProcess.MaxWorkingSet = loProcess.MaxWorkingSet;
                loProcess.Dispose();
            }
            catch { }
            System.Timers.Timer ShrinkTimer = new System.Timers.Timer();
            ShrinkTimer.Interval = 60000;
            ShrinkTimer.Elapsed += new System.Timers.ElapsedEventHandler(ShrinkTimer_Elapsed);
            ShrinkTimer.Start();
        }
        private void addToolStripMenuItem_Click(object sender, EventArgs e)
        {
            InsertItem insertItemForm = new InsertItem();

            insertItemForm.InsertItemEvent += new EventHandler <InsertItemEventArgs>(this.OnInsertItemEvent);
            insertItemForm.Show();
        }
        public CreateInsertLessonPage()
        {
            InitializeComponent();

            InputLanguageManager.Current.CurrentInputLanguage = CultureInfo.GetCultureInfo("ja-JP");

            InsertItem.ChangeSelectedColor();
        }
Exemplo n.º 4
0
        public object Post(InsertItem request)
        {
            var entity = request.ConvertTo <Item>();

            return(InTransaction(db =>
            {
                Logic.Add(entity);
                return new CommonResponse(Logic.GetById(entity.Id));
            }));
        }
Exemplo n.º 5
0
        public EditInsertLessonPage(Lesson lesson)
        {
            InitializeComponent();

            InputLanguageManager.Current.CurrentInputLanguage = CultureInfo.GetCultureInfo("ja-JP");

            InsertItem.ChangeSelectedColor();

            this.lesson = lesson;
        }
        /*
         * public IEnumerable<ReasonCode> GetReasonCodes()
         * {
         *  using (var context = new WarehouseRequisitionContext())
         *  {
         *      var reasonCodes = context.ReasonCode;
         *
         *      var firstRC = new ReasonCode
         *      {
         *          Code = "-- Reason Code --"
         *      };
         *
         *      var rcList = reasonCodes.ToList();
         *      rcList.Insert(0, firstRC);
         *      return rcList;
         *  }
         * }
         */
        internal int InsertDcjm(InsertItem insertItem)
        {
            using (var matContext = new MatAppContext())
            {
                try
                {
                    var errors = new List <string>();

                    if (insertItem.Quantity <= 0)
                    {
                        errors.Add("Quantity must be a positive number");
                    }
                    if (insertItem.Job.Length > 0)
                    {
                        var dcjmId = matContext.Database.ExecuteSqlCommand(@"INSERT INTO dcjm (trans_type, stat, trans_date, job, suffix, oper_num, item, whse, loc, qty, u_m, lot, override, emp_num)
                    VALUES ({0}, {1}, {2}, {3}, {4}, {5}, {6}, {7}, {8}, {9}, {10}, {11}, {12}, {13}); 
                    SELECT CAST(scope_identity() AS int)
                    ", insertItem.Quantity > 0 ? "1" : "2", "U", DateTime.Now, insertItem.Job.PadLeft(10), 0, (insertItem.OperNum != null ? Convert.ToInt32(insertItem.OperNum) : (int?)null), insertItem.Item, "MAIN", insertItem.Loc, insertItem.Quantity, insertItem.Um, (!String.IsNullOrWhiteSpace(insertItem.Lot)) ? insertItem.Lot.ToString() : null, 1, insertItem.ProcessedBy.PadLeft(7));

                        var dcjm = matContext.Dcjm.Where(i => i.TransNum == dcjmId).FirstOrDefault();

                        if (dcjm.ErrorMessage != null)
                        {
                            errors.Add(dcjm.ErrorMessage);
                        }
                    }
                    else
                    {
                        //The trans num field is not an identity field.  Just using a random number generator for the ID since its only an error processing table.
                        Random random         = new Random();
                        int    rand_trans_num = random.Next(1, 10000);
                        matContext.Database.ExecuteSqlCommand(@"INSERT INTO dcitem (trans_num, trans_type, stat, trans_date, item, whse, loc, count_qty, u_m, lot, reason_code, emp_num) 
                        VALUES ({0}, {1}, {2}, {3}, {4}, {5}, {6}, {7}, {8}, {9}, {10}, {11})", rand_trans_num, insertItem.Quantity > 0 ? "2" : "3", "U", DateTime.Now, insertItem.Item, "MAIN", insertItem.Loc, insertItem.Quantity, insertItem.Um, (!String.IsNullOrWhiteSpace(insertItem.Lot)) ? insertItem.Lot.ToString() : null, insertItem.Reasoncode.Substring(0, insertItem.Reasoncode.IndexOf("-")).Trim(), insertItem.ProcessedBy.PadLeft(7));

                        var dcitem = matContext.Dcitem.Where(i => i.TransNum == rand_trans_num).FirstOrDefault();
                        if (dcitem?.ErrorMessage != null)
                        {
                            errors.Add(dcitem.ErrorMessage);
                        }
                    }
                    //if any errors have been added to the errors list, return bad request.
                    if (errors.Count > 0)
                    {
                        string errorStr = String.Join("\n", errors);
                        throw new Exception(errorStr);
                    }

                    return(1);
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }
        }
Exemplo n.º 7
0
        private void chooseInsertParts_Click(object sender, RoutedEventArgs e)
        {
            foreach (InsertItem item in selectInsertsListbox.SelectedItems)
            {
                item.IsInsertText = true;
            }

            InsertItem.ChangeSelectedColor();

            selectInsertsListbox.SelectedItems.Clear();
        }
Exemplo n.º 8
0
        private void CreateCloze(Cloze cloze)
        {
            StringBuilder textBuilder    = new StringBuilder();
            StringBuilder insertsBuilder = new StringBuilder();

            for (int i = 0; i < selectInsertsListbox.Items.Count - 1; ++i)
            {
                InsertItem item1 = selectInsertsListbox.Items[i] as InsertItem;
                InsertItem item2 = selectInsertsListbox.Items[i + 1] as InsertItem;

                if (item1.InsertIndex == 0 && item2.InsertIndex == 0)
                {
                    textBuilder.Append(item1.Character);
                }

                if (item1.InsertIndex == 0 && item2.InsertIndex > 0)
                {
                    textBuilder.Append(item1.Character);
                    textBuilder.Append('_');
                    insertsBuilder.Append('_');
                }

                if (item1.InsertIndex > 0 && item2.InsertIndex > 0)
                {
                    insertsBuilder.Append(item1.Character);

                    if (item1.InsertIndex != item2.InsertIndex)
                    {
                        textBuilder.Append('_');
                        insertsBuilder.Append('_');
                    }
                }

                if (item1.InsertIndex > 0 && item2.InsertIndex == 0)
                {
                    insertsBuilder.Append(item1.Character);
                }
            }

            InsertItem item = selectInsertsListbox.Items[selectInsertsListbox.Items.Count - 1] as InsertItem;

            if (item.InsertIndex > 0)
            {
                insertsBuilder.Append(item.Character);
            }
            else
            {
                textBuilder.Append(item.Character);
            }

            cloze.Text    = textBuilder.ToString();
            cloze.Inserts = insertsBuilder.ToString().TrimStart('_');
            //cloze.Hints = hintsTextbox.Text.Replace("、", "_");
        }
Exemplo n.º 9
0
        private void RestoreClozeView(Cloze cloze)
        {
            StringBuilder textBuilder    = new StringBuilder();
            StringBuilder insertsBuilder = new StringBuilder();

            String[] textParts   = cloze.Text.Split('_');
            String[] insertParts = cloze.Inserts.Split('_');

            for (int i = 0; i < insertParts.Length; ++i)
            {
                textBuilder.Append(textParts[i]);
                textBuilder.Append(insertParts[i]);
            }

            textBuilder.Append(textParts.Last());

            sentenceTextbox.Text = textBuilder.ToString();
            //hintsTextbox.Text = cloze.Hints.Replace('_', '、');

            int insertsIndex = 0;

            foreach (char sign in cloze.Text)
            {
                InsertItem item;

                if (sign == '_')
                {
                    foreach (char insert in insertParts[insertsIndex])
                    {
                        item = new InsertItem(insert);
                        item.IsInsertText = true;

                        selectInsertsListbox.Items.Add(item);
                    }

                    InsertItem.ChangeSelectedColor();
                    ++insertsIndex;
                }
                else
                {
                    item = new InsertItem(sign);

                    selectInsertsListbox.Items.Add(item);
                }
            }
        }
Exemplo n.º 10
0
        /// <summary>
        /// SqlSugar与Dapper的性能比较
        /// </summary>
        /// <param name="args"></param>
        static void Main(string[] args)
        {
            WarmUp wu = new WarmUp();//预热处理

            //设置执行的DEMO
            string switchOn = "4";
            IDemos demo     = null;

            switch (switchOn)
            {
            //查询所有
            case "1": demo = new SelectBigData(); break;

            //查询单条
            case "2": demo = new SelectSingle(); break;

            //比拼海量数据更新
            case "3": demo = new UpdateList(); break;

            //比拼海量数据插入
            case "4": demo = new InsertList(); break;

            //比拼批量删除
            case "5": demo = new DeleteArray(); break;

            //分页
            case "6": demo = new Page(); break;

            //比拼普通插入
            case "7": demo = new InsertItem(); break;

            //比拼普通更新
            case "8": demo = new UpdateItem(); break;

            default: Console.WriteLine("switchOn的值错误,请输入正确的 case"); break;
            }
            demo.Init();
            Console.WriteLine("执行成功请关闭窗口");
            Console.ReadKey();
        }
Exemplo n.º 11
0
        internal void FillSaveScript(SQLScriptCollection collection)
        {
            switch (this.ColumnsStatus)
            {
            case STATUS.ASSIGNED:
            case STATUS.RAW:
                var script1 = collection.NewSQLScript(null, SQLTYPE.INSERT);
                var insert  = new InsertItem <TableEntity>(collection.accessor, Entity);
                Columns.ToList().ForEach(col =>
                {
                    var param = collection.NewParameter(col.Name, col.Value);
                    insert.Append(new Clause(script1.accessor, param.CoveredName, new KeyValuePair <string, object>[] { param.ToKeyValuePair() }));
                });
                script1.AddItem(insert);
                break;

            case STATUS.CHANGED:
                var script2 = collection.NewSQLScript(null, SQLTYPE.UPDATE);
                var update  = new UpdateItem <TableEntity>(collection.accessor, Entity);
                Columns.Where(c => c.Status == STATUS.CHANGED).ToList().ForEach(col =>
                {
                    var param = collection.NewParameter(col.Name, col.Value);
                    update.Append(new Clause(script2.accessor, string.Format("{0} = {1}", col.Name, param.CoveredName), new KeyValuePair <string, object>[] { param.ToKeyValuePair() }));
                });
                script2.AddItem(update);
                var where = new WhereItem(script2.accessor, update);
                Columns.Where(c => c.IsPK).ToList().ForEach(col =>
                {
                    var param = collection.NewParameter(col.Name, col.Value);
                    where.And(where.ColumnEquals(col.Name, param));
                });
                script2.AddItem(where);
                break;
            }

            foreach (var foreign in this.Foreigns)
            {
                foreign.Save(collection);
            }
        }
        public Requisition IssuePart(PartRequest partRequest)
        {
            using (var matContext = new MatAppContext())
            {
                using (var requisitionContext = new WarehouseRequisitionContext())
                {
                    var errors          = new List <string>();
                    var requisitionItem = requisitionContext.RequisitionItem.Where(r => r.Id == partRequest.ItemReqId).FirstOrDefault();

                    var requisitionId = requisitionContext.RequisitionItem.Where(r => r.Id == partRequest.ItemReqId).FirstOrDefault().RequisitionId;

                    var requisitionItems = requisitionContext.RequisitionItem.Where(r => r.RequisitionId == requisitionId).ToList();

                    var requisition = requisitionContext.Requisition.Where(r => r.RequisitionItem.Any(ri => ri.Id == partRequest.ItemReqId)).FirstOrDefault();


                    var item = matContext.Item.Where(i => i.Item1 == requisitionItem.Item).FirstOrDefault();

                    if (requisition != null)
                    {
                        if (requisitionItem != null)
                        {
                            if (item != null)
                            {
                                var insertItem = new InsertItem
                                {
                                    Quantity    = partRequest.Quantity,
                                    Job         = requisition.Job,
                                    OperNum     = requisitionItem.Operation,
                                    Item        = requisitionItem.Item,
                                    Loc         = partRequest.Location,
                                    Um          = item.Um,
                                    Lot         = partRequest.Lot,
                                    Reasoncode  = requisitionItem.ReasonCode,
                                    ProcessedBy = partRequest.ProcessedBy.Split(':')[0]
                                };

                                if (partRequest.Quantity <= 0)
                                {
                                    errors.Add("Quantity must be a positive number");
                                }

                                var result = InsertDcjm(insertItem);

                                if (result == 1)
                                {
                                    RequisitionItemActions requisitionItemActions = new RequisitionItemActions
                                    {
                                        Action            = "issue",
                                        RequisitionitemId = requisitionItem.Id,
                                        Quantity          = partRequest.Quantity,
                                        ActionBy          = partRequest.ProcessedBy,
                                        ActionDate        = DateTime.Now
                                    };
                                    requisitionItem.QuantityFilled += partRequest.Quantity;

                                    if (requisitionItem.QuantityFilled == requisitionItem.Quantity)
                                    {
                                        requisitionItem.Filled = true;
                                    }

                                    if ((requisitionItems.Count() == 1) && (requisitionItem.Filled == true))
                                    {
                                        requisition.Filled = true;
                                    }
                                    //if wholeReq.reqItem >= 1;
                                    //if for reqitem in wholeReq, if reqItem.filled ==true, req.filled = true. else, break

                                    ////MAYBE CONVERT TO CASE STATEMENT LATER
                                    if (requisitionItems.Count() > 1)
                                    {
                                        for (int i = 0; i < requisitionItems.Count(); i++)
                                        {
                                            if (requisitionItems[i].Filled == false)
                                            {
                                                requisition.Filled = false;
                                                break;
                                            }
                                            else
                                            {
                                                requisition.Filled = true;
                                            }
                                        }
                                    }
                                    if (errors.Count > 0)
                                    {
                                        string errorStr = String.Join("\n", errors);
                                        throw new Exception(errorStr);
                                    }
                                    try
                                    {
                                        requisitionContext.Update(requisition);
                                        requisitionContext.Update(requisitionItem);
                                        requisitionContext.Update(requisitionItemActions);
                                        requisitionContext.SaveChanges();
                                        return(requisitionContext.Requisition.Where(i => i.Id == requisitionItem.RequisitionId).FirstOrDefault());
                                    }
                                    catch (Exception ex)
                                    {
                                        throw ex;
                                    }
                                }
                            }
                        }
                    }

                    throw new Exception("No requisition found with id " + Convert.ToString(partRequest.ItemReqId));
                }
            }
        }