Example #1
0
 public void Save()
 {
     head.SampleType     = SampleType.校验样;
     CreateTime          = DateTime.Now;
     head.CreateUser     = LocalInfo.Current.user.ID;
     head.SaveVehSamples = true;
     head.SaveCheckItems = true;
     head.Save();
 }
Example #2
0
        private void 查询组批_Click(object sender, EventArgs e)
        {
            mixs.LoadDataByWhere("main.WLLX='熔剂' and main.SampleState=@SampleState", SampleState.初始状态);
            ches.LoadDataByWhere("main.WLLX='熔剂' and main.SampleState=@SampleState", SampleState.初始状态);
            if (ches.Count > 0)
            {
                for (int j = 0; j < ches.Count; j++)
                {
                    if (ches[j].Sample_Mix_ID == 0)
                    {
                        bool cunzai = false;
                        if (mixs.Count > 0)
                        {
                            for (int m = 0; m < mixs.Count; m++)
                            {
                                if (ches[j].SupplierCode == mixs[m].SupplierCode && ches[j].MatCode == mixs[m].MatCode && mixs[m].MixPlanCount > mixs[m].MixCount)
                                {
                                    cunzai = true;
                                    ches[j].Sample_Mix_ID = mixs[m].Sample_Mix_ID;
                                    ches[j].Save();
                                    mixs[m].MixCount++;
                                    mixs[m].Save();
                                }
                            }
                        }
                        if (cunzai == false)
                        {
                            QC_Material   matInfo = QC_Material.GetByID(ches[j].MatPK);
                            QC_Sample_Mix mix     = new QC_Sample_Mix();

                            mix.WpCode        = "0087";
                            mix.FangTong_Time = DateTime.Now;
                            mix.FangTong_User = LocalInfo.Current.user.ID;
                            mix.MatCode       = ches[j].MatCode;
                            mix.MatPK         = ches[j].MatPK;
                            mix.MixCount      = 1;
                            mix.MixPlanCount  = matInfo.BatchNum;
                            mix.SupplierCode  = ches[j].SupplierCode;
                            mix.MixUser       = LocalInfo.Current.user.ID;
                            mix.SampleState   = SampleState.初始状态;
                            mix.SampleType    = SampleType.普通样;
                            mix.WLLX          = ches[j].WLLX;
                            mix.CardID        = Zhc.Data.DbContext.GetSeq("RJ" + DateTime.Now.Date.ToString("yyyyMMdd"), 2);
                            mix.Save();
                            mixs.Add(mix);

                            ches[j].Sample_Mix_ID = mix.Sample_Mix_ID;
                            ches[j].Save();
                        }
                    }
                }
            }
        }
Example #3
0
        /// <summary>
        /// 保存
        /// </summary>
        private void btnSave_Click(object sender, EventArgs e)
        {
            QC_Sample_Mix sample = this.curData;

            veh.LoadDataByWhere("NoticeBillId=@NoticeBillId", this.curData.NoticeBillId);
            if (string.IsNullOrEmpty(sample.NoticeBillId))
            {
                MessageBox.Show("没有车辆信息,不能保存。");
                return;
            }

            if (string.IsNullOrEmpty(sample.CardID))
            {
                MessageBox.Show("还没有刷卡。");
                return;
            }
            if (veh.Count > 0)
            {
                sample.WLLX = veh[0].WLLX;
            }
            //if (veh[0].WLLX == "火运")
            //{ sample.NoticeBillId = veh[0].Sample_Veh_ID.ToString(); }
            sample.SampleType   = SampleType.抽查样;
            sample.Sample_Cylx  = this.Cylx;
            sample.MixCount     = 1;
            sample.MixPlanCount = 1;

            sample.SampleState = SampleState.组批完成;
            sample.Sample_TBZD = true;

            sample.ShouTong_User = LocalInfo.Current.user.ID;
            sample.ShouTong_Time = DateTime.Now;
            if (sample.DataState == DataRowState.Added)
            {
                sample.MixUser  = LocalInfo.Current.user.ID;
                sample.Mix_Time = DateTime.Now;
                examineSamples.Insert(0, sample);
            }
            sample.SaveCheckItems = true;

            sample.Save();
            btnUnBindCard.Visible = false;
            CreateSample();

            QC_Sample_Mix.UpdateInspectMainSample();

            MessageBox.Show("保存完成");
        }
Example #4
0
        private void timer1_Tick(object sender, EventArgs e)
        {
            mixs.LoadDataByWhere("main.WLLX='外矿' and main.SampleState=@SampleState", SampleState.初始状态);
            vehs.LoadDataByWhere("main.WLLX='外矿' and main.SampleState=@SampleState", SampleState.初始状态);

            for (int j = 0; j < vehs.Count; j++)
            {
                if (vehs[j].Sample_Mix_ID == 0)
                {
                    bool cunzai = false;
                    for (int m = 0; m < mixs.Count; m++)
                    {
                        if (vehs[j].SupplierCode == mixs[m].SupplierCode && vehs[j].MatCode == mixs[m].MatCode && mixs[m].MixPlanCount > mixs[m].MixCount)
                        {
                            cunzai = true;
                            vehs[j].Sample_Mix_ID = mixs[m].Sample_Mix_ID;
                            vehs[j].Save();
                            mixs[m].MixCount++;
                            mixs[m].Save();
                        }
                    }
                    if (cunzai == false)
                    {
                        QC_Material   matInfo = QC_Material.GetByID(vehs[j].MatPK);
                        QC_Sample_Mix mix     = new QC_Sample_Mix();

                        mix.WpCode = "0090";

                        mix.MatCode      = vehs[j].MatCode;
                        mix.MatPK        = vehs[j].MatPK;
                        mix.MixCount     = 1;
                        mix.MixPlanCount = matInfo.BatchNum;
                        mix.SupplierCode = vehs[j].SupplierCode;
                        mix.MixUser      = LocalInfo.Current.user.ID;
                        mix.SampleState  = SampleState.初始状态;
                        mix.SampleType   = SampleType.普通样;
                        mix.WLLX         = vehs[j].WLLX;
                        mix.CardID       = "WK" + Zhc.Data.DbContext.GetSeq(DateTime.Now.Date.ToString("yyyyMMdd"), 2);
                        mix.Save();
                        mixs.Add(mix);

                        vehs[j].Sample_Mix_ID = mix.Sample_Mix_ID;
                        vehs[j].Save();
                    }
                }
            }
        }
Example #5
0
        private void printDocument1_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
        {
            QC_Sample_Mix mix = this.qCSampleMixBindingSource.Current as QC_Sample_Mix;

            if (mix == null)
            {
                MessageBox.Show("请选择任务单");
            }
            else
            {
                string qydh  = QC_Sample_Mix.ShortStoreCode(mix.CardID);
                string head  = qydh;
                string body  = mix.MatName;
                string body1 = mix.SupplierName;
                mix.WCDY = true;
                mix.Save();

                Rectangle rect      = new Rectangle(9, 3, 112, 94);
                Font      f1        = new System.Drawing.Font("宋体", 21, FontStyle.Bold);
                SizeF     headSize  = e.Graphics.MeasureString(head, f1);
                Font      f2        = new System.Drawing.Font("宋体", 12f, FontStyle.Bold);
                SizeF     bodySize  = e.Graphics.MeasureString(body, f2);
                Font      f3        = new System.Drawing.Font("宋体", 12f, FontStyle.Bold);
                SizeF     body1Size = e.Graphics.MeasureString(body1, f2);

                float topMargin  = rect.Top + (rect.Height - headSize.Height - bodySize.Height - body1Size.Height - 6) / 2;
                float leftMargin = rect.Left + (rect.Width - headSize.Width) / 2;

                e.Graphics.DrawString(head, f1, Brushes.Black, new PointF(leftMargin, topMargin));

                float topMargin2  = topMargin + Math.Max(headSize.Height + 3, 12);
                float leftMargin2 = rect.Left;
                e.Graphics.DrawString(body, f2, Brushes.Black, new PointF(leftMargin2, topMargin2));

                float topMargin3  = topMargin2 + Math.Max(bodySize.Height + 2, 12);
                float leftMargin3 = rect.Left;
                e.Graphics.DrawString(body1, f2, Brushes.Black, new PointF(leftMargin3, topMargin3));
            }
        }
Example #6
0
        /// <summary>
        /// 保存
        /// </summary>
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(currentData.WpCode))
            {
                MessageBox.Show("作业点信息不能为空。");
                return;
            }
            if (string.IsNullOrEmpty(currentData.MatPK))
            {
                MessageBox.Show("物料信息不能为空。");
                return;
            }
            if (currentData.VehSamples.Count == 0)
            {
                MessageBox.Show("请先刷取样卡。");
                return;
            }

            currentData.SampleType = SampleType.校验样;

            currentData.ShouTong_User = LocalInfo.Current.user.ID;
            currentData.ShouTong_Time = DateTime.Now;
            currentData.MixPlanCount  = currentData.VehSamples.Count;

            if (currentData.DataState == DataRowState.Added)
            {
                currentData.SupplierCode = DbContext.GetSeq("校验样" + DateTime.Today.ToString("yyyyMMdd"), 2);
                currentData.MixUser      = LocalInfo.Current.user.ID;
                currentData.Mix_Time     = DateTime.Now;
                mixSamples.Insert(0, currentData);
            }

            currentData.SaveVehSamples = true;
            currentData.SaveCheckItems = true;
            currentData.Save();
            MessageBox.Show("保存成功");
        }
Example #7
0
        private void 组批_Click(object sender, EventArgs e)
        {
            this.hjvehs.Save();

            if (MessageBox.Show("确实要组批吗?", "提示", MessageBoxButtons.OKCancel) == DialogResult.OK)
            {
                Dictionary <string, List <QC_Sample_Veh> > vehFenzu = new Dictionary <string, List <QC_Sample_Veh> >();
                vehFenzu.Clear();

                foreach (var veh in hjvehs)
                {
                    if (veh.zp)
                    {
                        string key = veh.MatPK + "_" + veh.SupplierCode;
                        if (vehFenzu.ContainsKey(key))
                        {
                            vehFenzu[key].Add(veh);
                        }
                        else
                        {
                            vehFenzu.Add(key, new List <QC_Sample_Veh>()
                            {
                                veh
                            });
                        }
                    }
                }

                foreach (var item in vehFenzu)
                {
                    int           xiaotongshu = item.Value.Count;
                    int           datongshu   = 1;
                    QC_Sample_Veh tempVeh     = item.Value[0];

                    QC_Material matInfo = QC_Material.GetByCode(tempVeh.MatCode);
                    if (matInfo != null)
                    {
                        if (xiaotongshu <= matInfo.BatchNum)
                        {
                            datongshu = 1;
                        }
                        else if (xiaotongshu % matInfo.BatchNum == 0)
                        {
                            datongshu = item.Value.Count / matInfo.BatchNum;
                        }
                        else if (xiaotongshu % matInfo.BatchNum != 0)
                        {
                            datongshu = item.Value.Count / matInfo.BatchNum + 1;
                        }
                    }



                    if (datongshu > xiaotongshu)
                    {
                        datongshu = xiaotongshu;
                    }

                    Dictionary <int, List <int> > fp = FenZu(xiaotongshu, datongshu);
                    foreach (var fpItem in fp)
                    {
                        List <QC_Sample_Veh> vehs = new List <QC_Sample_Veh>();
                        foreach (var xtHao in fpItem.Value)
                        {
                            QC_Sample_Veh tempVeh2 = item.Value[xtHao];

                            vehs.Add(tempVeh2);
                        }
                        if (vehs.Count > 0)
                        {
                            QC_Sample_Mix mix = new QC_Sample_Mix();
                            mix.WpCode        = "0083";
                            mix.MatCode       = vehs[0].MatCode;
                            mix.MatPK         = vehs[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      = vehs.Count;
                            mix.MixPlanCount  = vehs.Count;
                            mix.SupplierCode  = vehs[0].SupplierCode;
                            mix.MixUser       = LocalInfo.Current.user.ID;
                            mix.SampleState   = SampleState.组批完成;
                            mix.SampleType    = SampleType.普通样;
                            mix.WLLX          = vehs[0].WLLX;
                            mix.CardID        = Zhc.Data.DbContext.GetSeq("HB" + DateTime.Now.Date.ToString("yyyyMMdd"), 2);
                            mix.Save();
                            hjmixs.Add(mix);
                            foreach (var veh in vehs)
                            {
                                veh.Sample_Mix_ID = mix.Sample_Mix_ID;
                                veh.Mix_Time      = DateTime.Now;
                                veh.SampleState   = SampleState.组批完成;
                                veh.Save();
                            }
                            QC_Sample_Mix mixpb = new QC_Sample_Mix();
                            mixpb.MatCode         = vehs[0].MatCode;
                            mixpb.MatPK           = vehs[0].MatPK;
                            mixpb.WpCode          = "0083";
                            mixpb.WLLX            = vehs[0].WLLX;
                            mixpb.Mix_Time        = DateTime.Now;
                            mixpb.FangTong_Time   = DateTime.Now;
                            mixpb.ShouTong_Time   = DateTime.Now;
                            mixpb.ShouTong_User   = LocalInfo.Current.user.ID;
                            mixpb.FangTong_User   = LocalInfo.Current.user.ID;
                            mixpb.MixCount        = vehs.Count;
                            mixpb.MixPlanCount    = vehs.Count;
                            mixpb.SupplierCode    = vehs[0].SupplierCode;
                            mixpb.MixUser         = LocalInfo.Current.user.ID;
                            mixpb.CardID          = "PB" + mix.CardID.Remove(0, 2);
                            mixpb.MainSampleMixId = mix.Sample_Mix_ID;
                            mixpb.SampleType      = SampleType.破包样;
                            mixpb.SampleState     = SampleState.组批完成;
                            mixpb.Save();
                        }
                    }
                }

                PrintZupi();
            }
        }
Example #8
0
        private void timer1_Tick(object sender, EventArgs e)
        {
            mixs.LoadDataByWhere("main.WLLX='石子' and main.SampleState=@SampleState", SampleState.初始状态);
            qvs.LoadDataByWhere("WLLX='石子' and status=7 order by begintime desc");

            for (int j = 0; j < qvs.Count; j++)
            {
                bool cunzai = false;
                for (int m = 0; m < mixs.Count; m++)
                {
                    if (qvs[j].CUSTCODE == mixs[m].SupplierCode && qvs[j].INVCODE == mixs[m].MatCode)
                    {
                        cunzai = true;

                        QC_Sample_Veh sm = new QC_Sample_Veh();
                        sm.begintime    = qvs[j].begintime;
                        sm.WpCode       = FrmMain.localinfo.workpoint.Code; //作业点编码
                        sm.FetchPerson  = LocalInfo.Current.user.ID;        //取样人ID
                        sm.VehNo        = qvs[j].Cph;                       //车牌号
                        sm.NoticeBillId = qvs[j].NoticeId;                  //磁卡作业单号
                        //    sm.Sample_Mix_ID = 0;                               //混样ID
                        sm.FetchTime = System.DateTime.Now;                 //取样时间

                        //     sm.KouShui = StringTool.FNumVal(koushui.Text);
                        //      sm.KouZa = StringTool.FNumVal(kouza.Text);
                        sm.WLLX         = "石子";
                        sm.NcDhdBodyId  = qvs[j].NcDhdBodyId;  //车辆作业单主键
                        sm.MatCode      = qvs[j].INVCODE;      //物料编码
                        sm.MatName      = qvs[j].INVNAME;
                        sm.SupplierCode = qvs[j].CUSTCODE;     //供应商编码
                        sm.SupplierName = qvs[j].CUSTNAME;
                        sm.MatPK        = qvs[j].PK_INVBASDOC; //物料主键

                        sm.NcDhdHeadNo = qvs[j].NcDhdHeadNo;   //NC到货单

                        sm.Sample_Mix_ID = mixs[m].Sample_Mix_ID;
                        sm.zpdh          = mixs[m].CardID;
                        sm.SampleState   = SampleState.初始状态;
                        sm.zptime        = DateTime.Now.ToString();
                        vehs.Add(sm);
                        DbContext.ExeSql("update tb_noticebill_head set status=8 where status=7  and noticebillid=@noticebillid", qvs[j].NoticeId);
                        vehs.Save();
                    }
                }
                if (cunzai == false)
                {
                    QC_Sample_Mix mix = new QC_Sample_Mix();

                    mix.WpCode  = "0091";
                    mix.MatCode = qvs[j].INVCODE;
                    mix.MatPK   = qvs[j].PK_INVBASDOC;
                    //  mix.MixCount = vehs.Count;
                    // mix.MixPlanCount = vehs.Count;
                    mix.SupplierCode = qvs[j].CUSTCODE;
                    mix.MixUser      = LocalInfo.Current.user.ID;
                    mix.SampleState  = SampleState.初始状态;
                    mix.SampleType   = SampleType.普通样;
                    mix.WLLX         = qvs[j].WLLX;
                    mix.CardID       = Zhc.Data.DbContext.GetSeq("SZ" + DateTime.Now.Date.ToString("yyyyMMdd"), 2);
                    mix.Save();
                    mixs.Add(mix);
                    QC_Sample_Veh sm = new QC_Sample_Veh();
                    sm.begintime    = qvs[j].begintime;
                    sm.WpCode       = FrmMain.localinfo.workpoint.Code; //作业点编码
                    sm.FetchPerson  = LocalInfo.Current.user.ID;        //取样人ID
                    sm.VehNo        = qvs[j].Cph;                       //车牌号
                    sm.NoticeBillId = qvs[j].NoticeId;                  //磁卡作业单号
                    //    sm.Sample_Mix_ID = 0;                               //混样ID
                    sm.FetchTime = System.DateTime.Now;                 //取样时间

                    //     sm.KouShui = StringTool.FNumVal(koushui.Text);
                    //      sm.KouZa = StringTool.FNumVal(kouza.Text);
                    sm.WLLX         = "石子";
                    sm.NcDhdBodyId  = qvs[j].NcDhdBodyId;  //车辆作业单主键
                    sm.MatCode      = qvs[j].INVCODE;      //物料编码
                    sm.MatName      = qvs[j].INVNAME;
                    sm.SupplierCode = qvs[j].CUSTCODE;     //供应商编码
                    sm.SupplierName = qvs[j].CUSTNAME;
                    sm.MatPK        = qvs[j].PK_INVBASDOC; //物料主键

                    sm.NcDhdHeadNo = qvs[j].NcDhdHeadNo;   //NC到货单

                    sm.Sample_Mix_ID = mix.Sample_Mix_ID;
                    sm.zpdh          = mix.CardID;
                    sm.SampleState   = SampleState.初始状态;
                    sm.zptime        = DateTime.Now.ToString();
                    vehs.Add(sm);
                    DbContext.ExeSql("update tb_noticebill_head set status=8 where status=7  and noticebillid=@noticebillid", qvs[j].NoticeId);
                    vehs.Save();
                }
            }
        }
Example #9
0
        //放桶
        private void simpleButton2_Click(object sender, EventArgs e)
        {
            //放桶
            if (CardID == "")
            {
                MessageBox.Show("请刷卡");
                return;
            }
            yxcard = false;
            DbEntityTable <BC_DT_State> dtwzs  = new DbEntityTable <BC_DT_State>();
            DbEntityTable <QC_IC_Info>  hycrds = new DbEntityTable <QC_IC_Info>();

            hycrds.LoadDataByWhere("CardID=@CardID and CardType=@CardType ", CardID, "CUT002");
            foreach (var qcic in hycrds)
            {
                if (qcic.SampleId == 0)
                {
                    yxcard           = true;
                    label3.Text      = System.DateTime.Now + "扫卡成功";
                    label3.ForeColor = Color.Red;
                }
                else
                {
                    MessageBox.Show("该卡已经使用");
                    return;    //该卡已经注册
                }
            }
            if (yxcard == true)   //是有效卡
            {
                if (sum > sjtnum)
                {
                    sjtnum = sjtnum + 1;
                    dtgs   = dtgs - 1;
                    if (dtgs > 0)
                    {
                        label5.Text = "需要" + dtgs + "个大桶!";
                        qyts ts = new qyts(label5.Text);

                        ts.ShowDialog();
                    }
                    else
                    {
                        label5.Text = "大桶已经放好!";
                        qyts ts = new qyts(label5.Text);
                        ts.ShowDialog();
                    }
                    int a = sjtnum + 1;
                    label2.Text      = "选择位置" + a;
                    label2.ForeColor = Color.Red;
                }
                else
                {
                    isfangtong  = false;
                    label5.Text = "大桶已经放好!";
                    qyts ts = new qyts(label5.Text);
                    ts.ShowDialog();
                    dtwzs.LoadDataByWhere("WpCode='" + workpointCode + "' and SHOUTONG_TIME IS NULL and WLLX='煤'");
                    this.bCDTStateBindingSource.DataSource = dtwzs;
                    return;
                }
                QC_Sample_Mix hy = new QC_Sample_Mix();

                object result = DbContext.ExecuteScalar("select max(TempID) from QC_Sample_Mix where SampleState=" + Convert.ToInt32(SampleState.初始状态) + " and WpCode='" + workpointCode + "' and WLLX='煤'");
                if (result != null && result != DBNull.Value)
                {
                    hy.TempID = Convert.ToInt32(result) + 1;             //目前有的大桶个数
                }
                else
                {
                    hy.TempID = 1;
                }

                hy.SampleState   = SampleState.初始状态;
                hy.WpCode        = workpointCode;
                hy.WLLX          = "煤";
                hy.CardID        = CardID;
                hy.FangTong_Time = System.DateTime.Now;

                hy.Save();

                if (isfangtong == false)
                {
                    DbEntityTable <QC_Sample_Veh> sxks = new DbEntityTable <QC_Sample_Veh>();
                    sxks.LoadDataByWhere("main.SAMPLESTATE=@SAMPLESTATE and WLLX='煤'", SampleState.初始状态);
                    foreach (var sxk in sxks)
                    {
                        sxk.SampleState = SampleState.开始组批;
                        sxk.Save();
                    }
                }

                isfangtong = true;    //正在放大桶
                DbEntityTable <QC_IC_Info> qcics = new DbEntityTable <QC_IC_Info>();
                qcics.LoadDataByWhere("CardID=@CardID and CardType=@CardType ", hy.CardID, "CUT002");
                foreach (var qcic in qcics)
                {
                    qcic.SampleId = hy.Sample_Mix_ID;
                    qcic.Save();
                    label3.Text      = System.DateTime.Now + "保存成功";
                    label3.ForeColor = Color.Red;
                }
                if (sum <= sjtnum)
                {
                    label5.Text = "大桶已经放好";
                    label2.Text = "";
                    isfangtong  = false;
                    dtwzs.LoadDataByWhere("WpCode='" + workpointCode + "' and SHOUTONG_TIME IS NULL and WLLX='煤'");
                    this.bCDTStateBindingSource.DataSource = dtwzs;
                    return;
                }
                CardID = "";
            }

            dtwzs.LoadDataByWhere("WpCode='" + workpointCode + "' and SHOUTONG_TIME IS NULL and WLLX='煤'");
            this.bCDTStateBindingSource.DataSource = dtwzs;
        }
Example #10
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();
        }
Example #11
0
        /// <summary>
        /// 绑扣
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button9_Click(object sender, EventArgs e)
        {
            if (CardID == "")
            {
                MessageBox.Show("请刷扣");
                return;
            }

            DbEntityTable <QC_IC_Info> hycrds = new DbEntityTable <QC_IC_Info>();

            hycrds.LoadDataByWhere("CardID=@CardID and CardType=@CardType ", CardID, "CUT002");

            if (hycrds.Count == 0)
            {
                CardID           = "";
                label2.Text      = "该扣类型不对!";
                label2.ForeColor = Color.Red;
                return;
            }



            var view = gridView2;

            if (mixDanHao.Count < 1)
            {
                MessageBox.Show("没有大样单号!请刷新");
                return;
            }
            QC_Sample_Mix bill = view.GetFocusedRow() as QC_Sample_Mix;

            if (bill == null)
            {
                MessageBox.Show("没有大样单号!");
                return;
            }
            bill.CardID    = CardID;
            bill.StoreCode = QC_Sample_Mix.FullStoreCode(bill.StoreCode);


            IDbConnection conn = DbContext.GetDefaultConnection();

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

            bill.Save(trans);
            foreach (var qcic in hycrds)
            {
                qcic.SampleId = bill.Sample_Mix_ID;
            }
            hycrds.Save(trans);
            trans.Commit();
            conn.Close();
            label2.Text = "";
            CardID      = "";

            //foreach (var item in mixDanHao)
            //{
            //    if (item.Sample_Mix_ID == bill.Sample_Mix_ID)
            //    {
            //        item.CardID = CardID;
            //        item.StoreCode = QC_Sample_Mix.FullStoreCode(bill.StoreCode);
            //        break;
            //    }
            //}
            //mixDanHao.Save();
            initDanHao();
        }