private void AddOrders(List <Machine> Machines)
        {
            MachineKeeper MachineKeeper = new MachineKeeper();

            MachineKeeper.LoadFromMes(new int[] { 1, 2, 3 });

            foreach (Machine mach in Machines.Where(m => m.IsSelected == true))
            {
                MesOrder mesOrder = new MesOrder();
                if (mach.Type == "g" || mach.Type == "p")
                {
                    mesOrder.Number = GetUniqueNumber(CreatePrefix() + mach.Name.Substring(0, 1) + mach.Number.ToString() + txtSuffix.Text);
                }
                else
                {
                    mesOrder.Number = GetUniqueNumber(CreatePrefix() + mach.Name.Substring(0, 2) + mach.Number.ToString() + txtSuffix.Text);
                }

                mesOrder.Name                = txtDescription.Text;
                mesOrder.Description         = txtDescription.Text;
                mesOrder.ScheduledStartDate  = txtStartDate.Value;
                mesOrder.ScheduledFinishDate = txtStartDate.Value.AddMinutes(Convert.ToInt32(txtLength.Text));
                mesOrder.Machine             = MachineKeeper.Machines.Where(m => m.MesNumber == mach.Name.Trim()).FirstOrDefault();
                mesOrder.Type                = (MesOrderType)cmbType.SelectedValue;
                mesOrder.Add();
            }
        }
Esempio n. 2
0
        public ResResultModel SaveMesOrder(MesOrderModel model)
        {
            try
            {
                if (model == null)
                {
                    return(ResResult.Response(false, MC.Request_Params_InvalidError, ""));
                }
                var bll      = new MesOrder();
                var effect   = 0;
                var oldModel = bll.GetModel(model.OBarcode, model.PBarcode, model.PdBarcode, model.PtBarcode);
                if (oldModel != null)
                {
                    oldModel.Qty += model.Qty;
                    effect        = bll.Update(oldModel);
                }
                else
                {
                    var currTime  = DateTime.Now;
                    var modelInfo = new MesOrderInfo(Guid.Empty, WebCommon.GetUserId(), model.OBarcode, model.PBarcode, model.PdBarcode, model.PtBarcode, model.Qty, currTime, currTime, 0, "", currTime);
                    effect = bll.Insert(modelInfo);
                }

                return(ResResult.Response(true, MC.M_Save_Ok, ""));
            }
            catch (Exception ex)
            {
                return(ResResult.Response(false, ex.Message, ""));
            }
        }
Esempio n. 3
0
        private void GetMesOrderList(HttpContext context, int pageIndex, int pageSize, string keyword)
        {
            var           bll         = new MesOrder();
            int           totalRecord = 0;
            StringBuilder sqlWhere    = null;
            ParamsHelper  parms       = null;

            if (!string.IsNullOrWhiteSpace(keyword))
            {
                parms    = new ParamsHelper();
                sqlWhere = new StringBuilder("and (OBarcode like @Keyword or PBarcode like @Keyword or PdBarcode like @Keyword or PtBarcode like @Keyword) ");
                var parm = new SqlParameter("@Keyword", SqlDbType.NVarChar, 50);
                parm.Value = parm.Value = "%" + keyword + "%";
                parms.Add(parm);
            }

            var list = bll.GetList(pageIndex, pageSize, out totalRecord, sqlWhere == null ? null : sqlWhere.ToString(), parms == null ? null : parms.ToArray());

            context.Response.Write(ResResult.ResJsonString(true, "", "{\"total\":" + totalRecord + ",\"rows\":" + JsonConvert.SerializeObject(list) + "}"));
        }