Ejemplo n.º 1
0
        public void quYang(string type)
        {
            if (sample_selected.Count < 1)
            {
                MessageBox.Show("没有勾选物料");
                return;
            }

            int       jq = 0, sq = 0;
            sampleNum sm = new sampleNum();

            sm.showDialogEx(type);
            if (sm.DialogResult != DialogResult.OK)
            {
                MessageBox.Show("没有确认取样的个数");
                return;
            }
            else
            {
                jq = sm.autoNum;
                sq = sm.manuNum;
                //cq = sm.chouNum;
            }

            if ((jq == 0) && (sq == 0))
            {
                MessageBox.Show("没有确认取样的个数");
                return;
            }


            int           mixid = 0;
            IDbConnection conn  = DbContext.GetDefaultConnection();

            conn.Open();
            IDbTransaction trans = conn.BeginTransaction();

            try

            {
                for (int i = 0; i < jq; i++)
                {
                    QC_Sample_Mix mix = new QC_Sample_Mix();
                    mix.WpCode          = "Huoyun";
                    mix.MatCode         = sample_selected[0].MatCode;
                    mix.MatPK           = sample_selected[0].MatPK;
                    mix.Mix_Time        = DateTime.Now;
                    mix.FangTong_Time   = DateTime.Now;
                    mix.ShouTong_Time   = DateTime.Now;
                    mix.ShouTong_User   = LocalInfo.Current.user.ID;
                    mix.FangTong_User   = LocalInfo.Current.user.ID;
                    mix.MixCount        = sample_selected.Count;
                    mix.MixPlanCount    = sample_selected.Count;
                    mix.SupplierCode    = sample_selected[0].SupplierCode;
                    mix.MixUser         = LocalInfo.Current.user.ID;
                    mix.SampleState     = SampleState.开始组批;
                    mix.SampleType      = SampleType.机器取样;
                    mix.WLLX            = sample_selected[0].WLLX;
                    mix.StoreCode       = Zhc.Data.DbContext.GetSeq("HY" + DateTime.Now.Date.ToString("yyyyMMdd"), 2);
                    mix.MainSampleMixId = mixid;
                    mix.Save(trans);
                    if (mixid == 0)
                    {
                        foreach (var veh in sample_selected)
                        {
                            veh.Sample_Mix_ID = mix.Sample_Mix_ID;
                            veh.Mix_Time      = DateTime.Now;
                            veh.SampleState   = SampleState.组批完成;
                            veh.SampleType    = SampleType.机器取样;
                            veh.Save(trans);
                        }
                        mixid = mix.Sample_Mix_ID;
                    }
                }

                for (int i = 0; i < sq; i++)
                {
                    QC_Sample_Mix mix = new QC_Sample_Mix();
                    mix.WpCode          = "Huoyun";
                    mix.MatCode         = sample_selected[0].MatCode;
                    mix.MatPK           = sample_selected[0].MatPK;
                    mix.Mix_Time        = DateTime.Now;
                    mix.FangTong_Time   = DateTime.Now;
                    mix.ShouTong_Time   = DateTime.Now;
                    mix.ShouTong_User   = LocalInfo.Current.user.ID;
                    mix.FangTong_User   = LocalInfo.Current.user.ID;
                    mix.MixCount        = sample_selected.Count;
                    mix.MixPlanCount    = sample_selected.Count;
                    mix.SupplierCode    = sample_selected[0].SupplierCode;
                    mix.MixUser         = LocalInfo.Current.user.ID;
                    mix.SampleState     = SampleState.开始组批;
                    mix.SampleType      = SampleType.人工取样;
                    mix.WLLX            = sample_selected[0].WLLX;
                    mix.StoreCode       = Zhc.Data.DbContext.GetSeq("HY" + DateTime.Now.Date.ToString("yyyyMMdd"), 2);
                    mix.MainSampleMixId = mixid;
                    mix.Save(trans);
                    if (mixid == 0)
                    {
                        foreach (var veh in sample_selected)
                        {
                            veh.Sample_Mix_ID = mix.Sample_Mix_ID;
                            veh.Mix_Time      = DateTime.Now;
                            veh.SampleState   = SampleState.组批完成;
                            veh.SampleType    = SampleType.人工取样;
                            veh.Save(trans);
                        }
                        mixid = mix.Sample_Mix_ID;
                    }
                }
                trans.Commit();
                conn.Close();
            }
            catch (Exception ex)
            {
                trans.Rollback();
                conn.Close();
                MessageBox.Show("出现异常,重新操作:" + ex.ToString());
                return;
            }



            print();
        }
Ejemplo n.º 2
0
        //抽取
        private void button8_Click(object sender, EventArgs e)
        {
            initTaskbill();
            if (sample_selected.Count > 0)
            {
                MessageBox.Show("已勾选其他物料,请先处理");
                return;
            }
            int       cq    = 0;
            long      vehno = 0;
            sampleNum sm    = new sampleNum();

            sm.showDialogEx("ChouQu");
            if (sm.DialogResult != DialogResult.OK)
            {
                MessageBox.Show("没有确认取样的个数");
                return;
            }
            else
            {
                cq    = sm.chouNum;
                vehno = sm.vehno;
            }

            if ((cq == 0))
            {
                MessageBox.Show("没有确认取样的个数");
                return;
            }
            if ((vehno == 0))
            {
                MessageBox.Show("没有输入车号");
                return;
            }

            sample_selected.LoadDataByWhere("vehno=@vehno order by fetchtime desc", vehno.ToString());

            if (sample_selected.Count < 1)
            {
                MessageBox.Show("输入的车号不存在!!");
                return;
            }


            DbEntityTable <QC_Sample_Mix> qc = new DbEntityTable <QC_Sample_Mix>();

            for (int i = 0; i < cq; i++)
            {
                QC_Sample_Mix mix = new QC_Sample_Mix();
                mix.WpCode        = "Huoyun";
                mix.MatCode       = sample_selected[0].MatCode;
                mix.MatPK         = sample_selected[0].MatPK;
                mix.Mix_Time      = DateTime.Now;
                mix.FangTong_Time = DateTime.Now;
                mix.ShouTong_Time = DateTime.Now;
                mix.ShouTong_User = LocalInfo.Current.user.ID;
                mix.FangTong_User = LocalInfo.Current.user.ID;
                mix.MixCount      = sample_selected.Count;
                mix.MixPlanCount  = sample_selected.Count;
                mix.SupplierCode  = sample_selected[0].SupplierCode;
                mix.MixUser       = LocalInfo.Current.user.ID;
                mix.SampleState   = SampleState.开始组批;
                mix.SampleType    = SampleType.抽查样;
                mix.WLLX          = sample_selected[0].WLLX;
                mix.StoreCode     = Zhc.Data.DbContext.GetSeq("HY" + DateTime.Now.Date.ToString("yyyyMMdd"), 2);
                //记住主样id
                mix.MainSampleMixId = sample_selected[0].Sample_Mix_ID;
                //记住车id
                mix.NoticeBillId = sample_selected[0].Sample_Veh_ID.ToString();
                qc.Add(mix);
            }
            qc.Save();
            print();

            //sample_selected[0].Sample_Mix_ID = mix.Sample_Mix_ID;
            //sample_selected[0].Mix_Time = DateTime.Now;
            //sample_selected[0].SampleType = SampleType.抽查样;
            //sample_selected[0].SampleState = SampleState.组批完成;
            //sample_selected[0].Save();
        }