Exemple #1
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();
                        }
                    }
                }
            }
        }
Exemple #2
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();
                    }
                }
            }
        }
Exemple #3
0
        public void jsdtgs1()
        {
            dtgs = 0;
            int fzcs = 0;
            //组抽样的
            DbEntityTable <cheshu> cheshucy = new DbEntityTable <cheshu>();

            cheshucy.LoadDataBySql("select SUPPLIERCODE as cj,MATCODE as wl,WPCODE as dd,COUNT(*) as num from QC_Sample_Veh where sample_mix_id=0 and sample_tbzd=1 and SampleState=@SampleState and WLLX='精粉' group by SUPPLIERCODE,MATCODE,WPCODE", SampleState.开始组批);
            foreach (var x in cheshucy)
            {
                dtgs = dtgs + x.num;
            }

            DbEntityTable <cheshu> cheshufl = new DbEntityTable <cheshu>();

            cheshufl.LoadDataBySql("select SUPPLIERCODE as cj,MATCODE as wl,WPCODE as dd,COUNT(*) as num from QC_Sample_Veh where sample_mix_id=0 and (sample_jy is null or sample_jy<>1) and sample_tbzd<>1 and SampleState=@SampleState and WLLX='精粉' group by SUPPLIERCODE,MATCODE,WPCODE", SampleState.开始组批);
            foreach (var x in cheshufl)
            {
                fzcs = 0;
                QC_Material matInfo = QC_Material.GetByCode(x.wl);
                if (matInfo != null)
                {
                    //  if (matInfo.InUse)
                    //  {

                    DbEntityTable <QC_MixRule> labrule = new DbEntityTable <QC_MixRule>();
                    labrule.LoadDataByWhere("MatNcId=@MatNcId and (CustCode=@CustCode or CustCode='' or CustCode is null) and VehNumber<=@VehNumber", matInfo.MatNcId, x.cj, x.num);
                    if (labrule.Count > 0)
                    {
                        if (labrule[0].PlanMixCount > 0)
                        {
                            fzcs = Convert.ToInt32(Math.Ceiling(Convert.ToDouble(x.num) / labrule[0].PlanMixCount));
                        }
                    }
                    if (fzcs > 0)
                    {
                        dtgs = fzcs + dtgs;
                    }
                    else
                    {
                        dtgs = dtgs + Convert.ToInt32(Math.Ceiling(Convert.ToDouble(x.num) / matInfo.BatchNum));
                    }
                    //  }
                }
            }
        }
Exemple #4
0
        public void zupi()
        {
            //按厂家,地点,物料分类
            int dtmax = 0;

            //组抽样的
            DbEntityTable <cheshu> cheshucy = new DbEntityTable <cheshu>();

            cheshucy.LoadDataBySql("select SUPPLIERCODE as cj,MATCODE as wl,WPCODE as dd  from QC_Sample_Veh where sample_mix_id=0 and sample_tbzd=1 and SampleState=@SampleState and WLLX='精粉'", SampleState.开始组批);
            foreach (var x in cheshucy)
            {
                dtmax = 1;
                zupiduoche(x.cj, x.wl, x.dd, dtmax, "抽样");
            }

            DbEntityTable <cheshu> cheshufl = new DbEntityTable <cheshu>();

            cheshufl.LoadDataBySql("select SUPPLIERCODE as cj,MATCODE as wl,WPCODE as dd,COUNT(*) as num from QC_Sample_Veh where sample_mix_id=0 and (sample_jy is null or sample_jy<>1) and sample_tbzd<>1 and SampleState=@SampleState and WLLX='精粉' group by SUPPLIERCODE,MATCODE,WPCODE ", SampleState.开始组批);

            foreach (var x in cheshufl)
            {
                //判定是否有车数比较多

                QC_Material matInfo = QC_Material.GetByCode(x.wl);
                if (matInfo != null)
                {
//                    if (matInfo.InUse)
//                  {
                    dtmax = matInfo.BatchNum;
                    DbEntityTable <QC_MixRule> labrule = new DbEntityTable <QC_MixRule>();
                    labrule.LoadDataByWhere("MatNcId=@MatNcId and (CustCode=@CustCode or CustCode='' or CustCode is null) and VehNumber<=@VehNumber", matInfo.MatNcId, x.cj, x.num);
                    if (labrule.Count > 0)
                    {
                        if (labrule[0].PlanMixCount > 0)
                        {
                            dtmax = labrule[0].PlanMixCount;
                        }
                    }

                    //                  }
                }
                zupiduoche(x.cj, x.wl, x.dd, dtmax, "正常样");
            }
        }
Exemple #5
0
        private void gridView1_FocusedRowObjectChanged(object sender, DevExpress.XtraGrid.Views.Base.FocusedRowObjectChangedEventArgs e)
        {
            if (btnSave.Enabled)
            {
                if (MessageBox.Show("原物料已经修改数据,是否保存?", "提示", MessageBoxButtons.YesNo) == DialogResult.Yes)
                {
                    btnSave_Click(null, null);
                }
            }

            this.selectedMaterial = e.Row as QC_Material;
            if (this.selectedMaterial == null)
            {
                selectedMatNcId = ""; xtraTabControl1.Visible = false; return;
            }
            if (this.selectedMaterial.MatNcId == "")
            {
                selectedMatNcId = ""; xtraTabControl1.Visible = false; return;
            }

            this.Cursor             = Cursors.WaitCursor;
            xtraTabControl1.Visible = true;

            selectedMatNcId = this.selectedMaterial.MatNcId;


            if (!string.IsNullOrEmpty(selectedMatNcId))
            {
                this.selectedMaterial.AllCheckItem.LoadDataByWhere("MATNCID=@MATNCID", selectedMatNcId);

                //DbEntityTable<QC_MatCheckItem_View>   MatCheckItemView=new DbEntityTable<QC_MatCheckItem_View>();
                //MatCheckItemView.LoadDataByWhere("MATNCID=@MATNCID", selectedMatNcId);
                //bool saveCheckItem = true;

                //foreach (QC_MatAllCheckItem item in this.selectedMaterial.AllCheckItem)
                //{
                //    item.JYLX = "可选";
                //}
                //foreach (var item in MatCheckItemView)
                //{
                //    var ci = this.selectedMaterial.AllCheckItem.FirstOrDefault<QC_MatAllCheckItem>((t) => t.CheckItemNcId == item.CheckItemNcId);
                //    if (ci == null)
                //    {
                //        QC_MatAllCheckItem qa = new QC_MatAllCheckItem();
                //        qa.MatNcId = selectedMatNcId;
                //        qa.CheckItemNcId = item.CheckItemNcId;
                //        qa.CheckItemCode = item.CheckItemCode;
                //        qa.CheckItemName = item.CheckItemName;
                //        qa.JYLX = "必检";
                //        this.selectedMaterial.AllCheckItem.Add(qa);
                //        saveCheckItem = true;
                //    }
                //    else
                //    {
                //        ci.JYLX = "必检";
                //    }
                //}

                //if (saveCheckItem) this.selectedMaterial.AllCheckItem.Save();

                this.selectedMaterial.MatCheckGroup.LoadByMatNcId(selectedMatNcId);
                this.selectedMaterial.MatQualityLevelView.LoadDataByWhere("MATNCID=@MATNCID", selectedMatNcId);
                this.selectedMaterial.ComplexMixRule.LoadDataByWhere("MATNCID=@MATNCID", selectedMatNcId);
                this.selectedMaterial.MatQualityRule.LoadDataByWhere("MATNCID=@MATNCID", selectedMatNcId);
                this.selectedMaterial.ComplexLabRule.LoadDataByWhere("MATNCID=@MATNCID", selectedMatNcId);
                this.selectedMaterial.ChgWaters.LoadDataByWhere("MATNCID=@MATNCID", selectedMatNcId);
                this.selectedMaterial.SaveEnable        = false;
                this.qCMaterialBindingSource.DataSource = this.selectedMaterial;
            }
            this.Cursor = Cursors.Default;
        }
Exemple #6
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();
            }
        }