public IHttpActionResult Post皮囊成型(皮囊成型 皮囊成型)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.皮囊成型.Add(皮囊成型);

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateException)
            {
                if (皮囊成型Exists(皮囊成型.Id))
                {
                    return(Conflict());
                }
                else
                {
                    throw;
                }
            }

            return(CreatedAtRoute("DefaultApi", new { id = 皮囊成型.Id }, 皮囊成型));
        }
        public IHttpActionResult Put皮囊成型(Guid id, 皮囊成型 皮囊成型)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != 皮囊成型.Id)
            {
                return(BadRequest());
            }

            db.Entry(皮囊成型).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!皮囊成型Exists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
        public IHttpActionResult GetNP(string id, Guid lb, Guid machine)
        {
            Guid guid;

            if (id.Length > 10)
            {
                guid = new Guid(id);
            }
            else
            {
                guid = db.HashTables.First(x => x.Hash == id).Id;
            }
            皮囊成型 皮囊成型 = db.皮囊成型s.Single <皮囊成型>(x => x.Id == guid && x.除 == false);


            if (皮囊成型 == null)
            {
                return(NotFound());
            }
            皮囊成型.作业员  = lb;
            皮囊成型.生产时间 = DateTime.Now;
            皮囊成型.生产机台 = machine;
            db.SubmitChanges();

            return(Ok(皮囊成型));
        }
        public IHttpActionResult Get皮囊成型(Guid id)
        {
            皮囊成型 皮囊成型 = db.皮囊成型.Find(id);

            if (皮囊成型 == null)
            {
                return(NotFound());
            }

            return(Ok(皮囊成型));
        }
        public IHttpActionResult GetCP(string id, Guid lb, Guid machine, float temp, float time)
        {
            Guid guid;

            if (id.Length > 10)
            {
                guid = new Guid(id);
            }
            else
            {
                guid = db.HashTables.First(x => x.Hash == id).Id;
            }
            皮囊成型 皮囊成型 = db.皮囊成型s.Single <皮囊成型>(x => x.Id == guid && x.除 == false);

            try
            {
                var n = db.皮囊硫化s.Single(x => x.除 == false && x.成型皮囊 == guid);
                n.硫化时间 = time;
                n.硫化温度 = temp;
                n.作业员  = lb;
                n.生产机台 = machine;
                db.SubmitChanges();
                return(Ok(n));
            }
            catch (Exception)
            {
                //throw;
            }

            if (皮囊成型 == null)
            {
                return(NotFound());
            }
            皮囊硫化 皮囊硫化 = new 皮囊硫化();

            皮囊硫化.Id   = Guid.NewGuid();
            皮囊硫化.硫化时间 = time;
            皮囊硫化.硫化温度 = temp;
            皮囊硫化.作业员  = lb;
            皮囊硫化.生产时间 = DateTime.Now;
            皮囊硫化.登记时间 = DateTime.Now;
            皮囊硫化.生产机台 = machine;
            皮囊硫化.成型皮囊 = guid;
            皮囊硫化.产品型号 = 皮囊成型.产品型号;
            db.皮囊硫化s.InsertOnSubmit(皮囊硫化);
            db.SubmitChanges();

            return(Ok(皮囊硫化));
        }
        private void btnCreate_Click(object sender, EventArgs e)
        {
            if (cbTypeNo.Text.Trim() == "")
            {
                MessageBox.Show("请输入产品型号");
                return;
            }
            int num = 0;

            if (!CheckInput(tbNum, "请输入要生成的数量", ref num))
            {
                return;
            }
            float outrubberconsume = 0;

            if (!CheckInput(tbOutRubberConsume, "请输入要消耗的外层胶数量", ref outrubberconsume))
            {
                return;
            }
            float innerrubberconsume = 0;

            if (!CheckInput(tbInnerRubberConsume, "请输入要消耗的内层胶数量", ref innerrubberconsume))
            {
                return;
            }
            float fabricconsume = 0;

            if (!CheckInput(tbFabricConsume, "请输入要消耗的帘布数量", ref fabricconsume))
            {
                return;
            }
            if (dgOutRubber.SelectedRows.Count < 0)
            {
                MessageBox.Show("请选择胶料");
                return;
            }
            if (dgFabric.SelectedRows.Count < 0)
            {
                MessageBox.Show("请选择帘布卷");
                return;
            }

            List <string> all = new List <string>();

            using (TransactionScope scope = new TransactionScope())
            {
                产品消耗 consume = null;
                if (cbTypeNo.SelectedValue == null)
                {
                    consume        = null;
                    consume        = new 产品消耗();
                    consume.Id     = Guid.NewGuid();
                    consume.产品名称   = cbTypeNo.Text;
                    consume.内层胶消耗量 = innerrubberconsume;
                    consume.外层胶消耗量 = outrubberconsume;
                    consume.帘布消耗量  = fabricconsume;
                    consume.加入日期   = DateTime.Now;
                    ddc.产品消耗s.InsertOnSubmit(consume);
                }

                if (cbTypeNo.SelectedValue != null)
                {
                    consume        = ddc.产品消耗s.First(x => x.Id == new Guid(cbTypeNo.SelectedValue.ToString()));
                    consume.内层胶消耗量 = innerrubberconsume;
                    consume.外层胶消耗量 = outrubberconsume;
                    consume.帘布消耗量  = fabricconsume;
                }
                for (int i = 0; i < num; i++)
                {
                    皮囊成型 temp = new 皮囊成型();
                    temp.Id    = Guid.NewGuid();
                    temp.产品型号  = cbTypeNo.Text;
                    temp.外胶片批号 = new Guid(dgOutRubber.SelectedRows[0].Cells[0].Value.ToString());
                    temp.帘布批号  = new Guid(this.dgFabric.SelectedRows[0].Cells[0].Value.ToString());
                    temp.内胶片批号 = new Guid(dgInnerRubber.SelectedRows[0].Cells[0].Value.ToString());
                    temp.产品消耗  = consume.Id;
                    temp.登记时间  = DateTime.Now;
                    ddc.皮囊成型s.InsertOnSubmit(temp);


                    HashTable hash = new HashTable();
                    hash.Id    = temp.Id;
                    hash.Table = "NP";
                    hash.Hash  = Utilizity.GetCRC32Str(temp.Id.ToString());
                    ddc.HashTables.InsertOnSubmit(hash);
                    all.Add(hash.Hash);
                }
                ddc.SubmitChanges();
                scope.Complete();
            }
            //LoadData();
            //打印二维码
            if (DialogResult.Yes == MessageBox.Show("你需要立即打印吗?", "询问", MessageBoxButtons.YesNo, MessageBoxIcon.Question))
            {
                IQRPrinter printer = QRPrinterFactory.GetQRPrinter();

                List <List <string> > ArrayList = all.Select((x, i) => new { Index = i, Value = x }).GroupBy(x => x.Index / 3).Select(x => x.Select(v => v.Value).ToList()).ToList();

                foreach (var items in ArrayList)
                {
                    string[] datas = new string[items.Count];
                    for (int i = 0; i < items.Count; i++)
                    {
                        datas[i] = Utilizity.CreateQRCodeStr(TableType.NP, items[0].ToString());
                    }

                    if (!printer.PrintQRCode(datas))
                    {
                        MessageBox.Show("打印错误,请重新生成成品代码", "警告", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }
                }
            }
            LoadData();
        }