Beispiel #1
0
        public WP_ChaXun()
        {
            InitializeComponent();
            this.dateEdit1.Text = DateTime.Now.AddDays(-1).ToString();
            this.dateEdit2.Text = DateTime.Now.ToString();
            // 初始化物料名称

            this.comboBoxEdit2.Properties.Items.Add("全部");
            vehs.LoadDataBySql("select distinct (h.INVNAME) as MatName from QC_Sample_Veh t ,BD_INVBASDOC h where h.PK_INVBASDOC=t.MatPK");
            foreach (var a in vehs)
            {
                this.comboBoxEdit2.Properties.Items.Add(a.MatName);
            }
        }
Beispiel #2
0
        public static QC_CheckMaxMinVal GetMaxMinVal(string rq, string supplierCode, string matNcId)
        {
            DbEntityTable <QC_CheckMaxMinVal> table = new DbEntityTable <QC_CheckMaxMinVal>();

            table.LoadDataBySql("select max(cast(CheckVal as float)) as MaxVal,min(cast(CheckVal as float)) as MinVal from QC_MixSampleValue_V where SampleState>=" + (int)SampleState.化验审核完成 + " and SampleType=" + (int)SampleType.普通样 + "and CHECKITEMCODE='10001' and checkVal<>'' and convert(varchar(10),Mix_Time,120)=@rq and SUPPLIERCODE=@SUPPLIERCODE and MATPK=@MATPK", rq, supplierCode, matNcId);
            if (table.Count > 0)
            {
                return(table[0]);
            }
            else
            {
                return(null);
            }
        }
Beispiel #3
0
        private void WP_Zhkcx_Load(object sender, EventArgs e)
        {
            this.gridControl1.DataSource = cxs;
            List <String> wl = new List <String>();

            wl.Add("全部");
            vehs.LoadDataBySql("select distinct (h.INVNAME) as MatName from QC_Sample_Veh t ,BD_INVBASDOC h where h.PK_INVBASDOC=t.MatPK");
            foreach (var item in vehs)
            {
                if (!wl.Contains(item.MatName) && item.MatName != "")
                {
                    wl.Add(item.MatName);
                }
            }
            vehs.Clear();
            comboBox2.DataSource = wl;
        }
Beispiel #4
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));
                    }
                    //  }
                }
            }
        }
Beispiel #5
0
        private void simpleButton1_Click(object sender, EventArgs e)
        {
            switch (this.comboBoxEdit1.Text)
            {
            case "全部":
                if (this.comboBoxEdit2.Text == "全部")
                {
                    vehs.LoadDataByWhere("main.FetchTime >= @begintime and main.FetchTime<=@endtime order by main.FetchTime ", this.dateEdit1.Text, this.dateEdit2.Text);
                }
                else
                {
                    vehs.LoadDataByWhere("main.FetchTime >= @begintime and main.FetchTime<=@endtime and  dhd.INVNAME  =@MatName order by main.FetchTime", this.dateEdit1.Text, this.dateEdit2.Text, this.comboBoxEdit2.Text);
                }

                vehscount.LoadDataBySql("select DISTINCT(t.sample_mix_id) from QC_Sample_Mix t,QC_Sample_Veh h where t.Sample_Mix_ID=h.Sample_Mix_ID and h.FetchTime >= @begintime and h.FetchTime<=@endtime", this.dateEdit1.Text, this.dateEdit2.Text);
                this.textEdit1.Text = vehscount.Count.ToString();
                break;

            case "快样":
                if (this.comboBoxEdit2.Text == "全部")
                {
                    vehs.LoadDataByWhere("main.FetchTime >= @begintime and main.FetchTime<=@endtime and mix.SAMPLETYPE>0 and main.mix_TIME is null order by main.FetchTime", this.dateEdit1.Text, this.dateEdit2.Text);
                }
                else
                {
                    vehs.LoadDataByWhere("main.FetchTime >= @begintime and main.FetchTime<=@endtime and mix.SAMPLETYPE>0 and main.mix_TIME is null and  dhd.INVNAME  =@MatName order by main.FetchTime", this.dateEdit1.Text, this.dateEdit2.Text, this.comboBoxEdit2.Text);
                }
                this.textEdit1.Text = vehs.Count.ToString();
                break;

            case "抽查样":
                if (this.comboBoxEdit2.Text == "全部")
                {
                    vehs.LoadDataByWhere("main.FetchTime >= @begintime and main.FetchTime<=@endtime and mix.SampleType=1 order by main.FetchTime", this.dateEdit1.Text, this.dateEdit2.Text);
                }
                else
                {
                    vehs.LoadDataByWhere("main.FetchTime >= @begintime and main.FetchTime<=@endtime and mix.SampleType=1  and  dhd.INVNAME  =@MatName order by main.FetchTime", this.dateEdit1.Text, this.dateEdit2.Text, this.comboBoxEdit2.Text);
                }
                this.textEdit1.Text = vehs.Count.ToString();
                break;
            }

            this.vehSamplesBindingSource.DataSource = vehs;
        }
Beispiel #6
0
        /// <summary>
        /// 初始化火车皮号选择下拉框
        /// </summary>
        public void initcmbHCPH()
        {
            DbEntityTable <View_train> train_num = new DbEntityTable <View_train>();

            // train_num.LoadDataBySql("select distinct(cardid) from  QC_Sample_Veh where samplestate=@samplestate and wllx=@wllx", Xg.Lab.Sample.SampleState.初始状态,"火运");
            train_num.LoadDataBySql("select distinct(zpdh+'_'+rwdh) as cardid from  QC_Sample_Veh where samplestate=@samplestate and wllx=@wllx", Xg.Lab.Sample.SampleState.初始状态, "火运");
            cmbHCPH.DataSource = train_num;

            if (train_num.Count > 0)
            {
                cmbHCPH.SelectedIndex = 0;
            }
            else
            {
                cmbHCPH.Text = "";
                initHCgrid();
            }
        }
Beispiel #7
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, "正常样");
            }
        }
Beispiel #8
0
        private void 查询_Click(object sender, EventArgs e)
        {
            cxs.Clear();
            QC_Sample_Mix mix = new QC_Sample_Mix();

            zyMixSamples.LoadDataByWhere("main.Mix_Time>=@Kssj and main.Mix_Time<=@Jssj and main.samplestate=11 and main.WLLX='煤'  order by  main.ZyDanHao ", DateTime.Parse(this.dateEdit1.Text.Trim()), DateTime.Parse(this.dateEdit2.Text.Trim()));



            for (int i = 0; i < zyMixSamples.Count; i++)
            {
                if (zyMixSamples[i].SampleType == SampleType.抽查样)
                {
                    zyMixSamples[i].VehSamples.LoadDataByNoticeBillId(zyMixSamples[i].NoticeBillId);
                    int parentId = InspectSampleParentId(zyMixSamples[i].Sample_Mix_ID);

                    if (zyMixSamples[i].daycheck() == 0)
                    {
                        zyMixSamples[i].CheckVals.LoadInspectSampleAllData(zyMixSamples[i].Sample_Mix_ID, parentId);
                    }
                    else
                    {
                        zyMixSamples[i].CheckVals.LoadInspectHotAllData(zyMixSamples[i].Sample_Mix_ID, parentId, zyMixSamples[i].daycheck(), "发热量1");
                    }
                }
                else if (zyMixSamples[i].SampleType == SampleType.普通样)
                {
                    zyMixSamples[i].VehSamples.LoadDataBySampleMixId(zyMixSamples[i].Sample_Mix_ID);

                    if (zyMixSamples[i].daycheck() == 0)
                    {
                        zyMixSamples[i].CheckVals.LoadZhengSampleAllData(zyMixSamples[i].Sample_Mix_ID);
                    }
                    else
                    {
                        zyMixSamples[i].CheckVals.LoadHotData(zyMixSamples[i].daycheck(), zyMixSamples[i].Sample_Mix_ID, "发热量1");
                    }
                }


                DbEntityTable <QC_MatAllCheckItem> matcheckitems = new DbEntityTable <QC_MatAllCheckItem>();

                matcheckitems.LoadDataByWhere("MATNCID=@MATNCID", zyMixSamples[i].MatPK);

                if (matcheckitems.Count > 0)
                {
                    foreach (var item in matcheckitems)
                    {
                        if (item.CheckGroupName == "可磨样")
                        {
                            bool czkm = false;
                            foreach (var it in zyMixSamples[i].CheckGroupLabs)
                            {
                                if (it.CheckGroupName == "可磨样")
                                {
                                    czkm = true;
                                }
                            }
                            if (!czkm)
                            {
                                DbEntityTable <QC_Sample_Mix> lishimixs = new DbEntityTable <QC_Sample_Mix>();
                                string SQL = "select * from QC_Sample_Mix where MatCode='" + zyMixSamples[i].MatCode + "' and SupplierCode='" + zyMixSamples[i].SupplierCode + "' and mix_time>='" + zyMixSamples[i].ZyRecvTime.Value.Date + "'  and mix_time<'" + zyMixSamples[i].ZyRecvTime + "' order by ZyRecvTime desc";
                                lishimixs.LoadDataBySql(SQL);
                                foreach (var li in lishimixs)
                                {
                                    bool czkmy = false;
                                    DbEntityTable <QC_Sample_Lab> labs = new DbEntityTable <QC_Sample_Lab>();
                                    labs.LoadDataByWhere("main.Sample_Mix_ID=@Sample_Mix_ID", li.Sample_Mix_ID);
                                    foreach (var it in labs)
                                    {
                                        if (it.CheckGroupName == "可磨样")
                                        {
                                            DbEntityTable <QC_Sample_Value> vals = new DbEntityTable <QC_Sample_Value>();
                                            vals.LoadDataByWhere("main.Sample_Lab_ID=@Sample_Lab_ID", it.Sample_Lab_ID);
                                            foreach (var va in vals)
                                            {
                                                va.ValSource = "前样";
                                                zyMixSamples[i].CheckVals.Add(va);
                                            }
                                            czkmy = true;
                                            break;
                                        }
                                    }
                                    if (czkmy)
                                    {
                                        break;
                                    }
                                }
                            }
                        }
                    }
                }



                zyMixSamples[i].CheckVals.DefaultSort();
                if (zyMixSamples[i].SampleType == SampleType.普通样)
                {
                    zyMixSamples[i].CheckVals.DaoxuSort();
                }
                DbEntityTable <QC_MatQualityLevel_View> levels = new DbEntityTable <QC_MatQualityLevel_View>();
                levels.LoadDataByWhere("QUALITYLEVELID=@QUALITYLEVELID", zyMixSamples[i].QualityLevelID);
                for (int j = 0; j < zyMixSamples[i].VehSamples.Count; j++)
                {
                    QC_SCNCcx cx = new QC_SCNCcx();

                    cx.VehNo      = zyMixSamples[i].VehSamples[j].VehNo;
                    cx.FetchTime  = zyMixSamples[i].VehSamples[j].FetchTime;
                    cx.KouShui    = zyMixSamples[i].VehSamples[j].KouShui;
                    cx.KouZa      = zyMixSamples[i].VehSamples[j].KouZa;
                    cx.SampleType = zyMixSamples[i].SampleType;
                    cx.ZyDanHao   = zyMixSamples[i].ZyDanHao;
                    cx.Wlmc       = zyMixSamples[i].MatName;
                    //    cx.Riqi = zyMixSamples[i].Mix_Time.Value.ToString("yyyy-MM-dd");
                    cx.Gysmc = zyMixSamples[i].SupplierName;
                    cx.Pddj  = levels[0].QUALITYLEVELNAME;

                    foreach (var item in zyMixSamples[i].CheckVals)
                    {
                        if (item.CheckItemName == "水分")
                        {
                            if (cx.Sf == "")
                            {
                                cx.Sf = item.ReportVal;
                            }
                        }
                        if (item.CheckItemName == "哈氏可磨性")
                        {
                            if (cx.KM == "")
                            {
                                cx.KM = item.ReportVal;
                            }
                        }
                        else if (item.CheckItemName == "灰分")
                        {
                            if (cx.Hf == "")
                            {
                                cx.Hf = item.ReportVal;
                            }
                        }
                        else if (item.CheckItemName == "挥发分")
                        {
                            if (cx.Hff == "")
                            {
                                cx.Hff = item.ReportVal;
                            }
                        }
                        else if (item.CheckItemName == "硫分")
                        {
                            if (cx.Lf == "")
                            {
                                cx.Lf = item.ReportVal;
                            }
                        }
                        else if (item.CheckItemName == "S")
                        {
                            if (cx.Lf == "")
                            {
                                cx.Lf = item.ReportVal;
                            }
                        }
                        else if (item.CheckItemName == "X")
                        {
                            if (cx.X == "")
                            {
                                cx.X = item.ReportVal;
                            }
                        }
                        else if (item.CheckItemName == "Y")
                        {
                            if (cx.Y == "")
                            {
                                cx.Y = item.ReportVal;
                            }
                        }
                        else if (item.CheckItemName == "G")
                        {
                            if (cx.G == "")
                            {
                                cx.G = item.ReportVal;
                            }
                        }

                        else if (item.CheckItemName == "发热量1")
                        {
                            if (cx.Frl == "")
                            {
                                cx.Frl = item.ReportVal;
                            }
                        }
                        else if (item.CheckItemName == "标准差S")
                        {
                            if (cx.BzcS == "")
                            {
                                cx.BzcS = item.ReportVal;
                            }
                        }
                        else if (item.CheckItemName == "Rmax")
                        {
                            if (cx.Rmax == "")
                            {
                                cx.Rmax = item.ReportVal;
                            }
                        }
                        else if (item.CheckItemName == "Rran")
                        {
                            if (cx.Rran == "")
                            {
                                cx.Rran = item.ReportVal;
                            }
                        }
                        else if (item.CheckItemName == "固定碳")
                        {
                            if (cx.Gdt == "")
                            {
                                cx.Gdt = item.ReportVal;
                            }
                        }
                    }
                    cxs.Add(cx);
                }
            }
        }
Beispiel #9
0
        private void zupiduoche(string cj, String wl, string zyd, int dtmax, string type)
        {
            int k    = 0;
            int dyid = 0;

            DbEntityTable <QC_Sample_Veh> xks = new DbEntityTable <QC_Sample_Veh>();

            string zpwpcode = "";

            object result = DbContext.ExecuteScalar("select NextWPCode from QC_WpRoute where  WpCode='" + zyd + "'");

            if (result != null && result != DBNull.Value)
            {
                zpwpcode = Convert.ToString(result);             //NC到货单
            }
            if (type == "抽样")
            {
                xks.LoadDataBySql("select * from QC_Sample_Veh where SUPPLIERCODE=@SUPPLIERCODE and MATCODE=@MATCODE and WPCODE=@WPCODE and sample_mix_id=0 and sample_tbzd=1 and SAMPLESTATE=@SAMPLESTATE and WLLX='煤'", cj, wl, zyd, SampleState.开始组批);
            }

            if (type == "正常样")
            {
                xks.LoadDataByWhere("main.SUPPLIERCODE=@SUPPLIERCODE and main.MATCODE=@MATCODE and main.WPCODE=@WPCODE and main.sample_mix_id=0 and (main.sample_jy is null or main.sample_jy<>1) and main.sample_tbzd<>1  and main.SAMPLESTATE=@SAMPLESTATE and WLLX='煤'", cj, wl, zyd, SampleState.开始组批);
                // xks.LoadDataBySql("select * from QC_Sample_Veh where SUPPLIERCODE=@SUPPLIERCODE and MATCODE=@MATCODE and WPCODE=@WPCODE and sample_mix_id=0 and (sample_jy is null or sample_jy<>1) and sample_tbzd<>1  and SAMPLESTATE=@SAMPLESTATE ", cj, wl, zyd, SampleState.开始组批);
                xks.Sort((v1, v2) => v1.Pxsl.CompareTo(v2.Pxsl));
            }



            foreach (var xk in xks)
            {
                k = k + 1;
                if ((k + dtmax - 1) % dtmax == 0 && wl == xk.MatCode && cj == xk.SupplierCode && zyd == xk.WpCode)
                {
                    DbEntityTable <QC_Sample_Mix> dty = new DbEntityTable <QC_Sample_Mix>();
                    dty.LoadDataByWhere("main.SampleState=@SampleState and main.WpCode=@WpCode and main.WLLX='煤'", SampleState.初始状态, zpwpcode);
                    int cishu = 1;
                    if (dty.Count == 0)
                    {
                        label6.Text = "大桶不够了";
                        return;
                    }
                    foreach (var hy in dty)
                    {
                        //只取一个大桶
                        cishu = cishu + 1;
                        if (cishu == 2)
                        {
                            hy.MatPK        = xk.MatPK;                  //物料主键
                            hy.Mix_Time     = System.DateTime.Now;       //混样时间
                            hy.SupplierCode = xk.SupplierCode;           //供应商
                            hy.MatCode      = xk.MatCode;                //物料编码
                            hy.MixUser      = LocalInfo.Current.user.ID; //混样人
                            hy.Sample_TBZD  = xk.SAMPLE_TBZD;
                            hy.SampleType   = xk.SampleType;             //样品类型
                            hy.SampleState  = SampleState.开始组批;          //样品状态
                            hy.Save();
                            dyid = hy.Sample_Mix_ID;
                        }
                    }
                }
                if (dyid > 0)
                {
                    xk.Sample_Mix_ID = dyid;
                    xk.SampleState   = SampleState.组批完成;
                    xk.Save();
                    label6.Text = "组批完成";
                }
                DbEntityTable <QC_Sample_Mix> jhplans = new DbEntityTable <QC_Sample_Mix>();
                jhplans.LoadDataByWhere("main.sample_mix_id=@sample_mix_id", dyid);
                foreach (var hy in jhplans)
                {
                    object result1 = DbContext.ExecuteScalar("select count(*) as num from QC_Sample_Veh where sample_mix_id=@sample_mix_id", hy.Sample_Mix_ID);
                    if (result1 != null && result1 != DBNull.Value)
                    {
                        hy.MixPlanCount = Convert.ToInt32(result1);            //桶个数
                    }
                    hy.Save();
                }
            }
            isfangtong = false;
        }