コード例 #1
0
        public static bool CheckTrSnHasStockOut(string trsn, string stockno)
        {
            try
            {
                //查询TrSn
                Dictionary <string, object> dic = new Dictionary <string, object>();

                dic.Add("tr_sn", trsn);
                //dic.Add("status", "2");
                dic.Add("stock_out_no", stockno);

                SearchRInventoryDetail sb = new SearchRInventoryDetail(dic);
                sb.ExecuteQuery();
                DataTable dt = sb.GetResult();

                if (dt == null || dt.Rows.Count == 0)
                {
                    return(false);
                }

                return(true);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
コード例 #2
0
        //查询该工单已出库的数量
        public static List <string> SearchTrSnFromRInventoryDetailByStockOutNo(string woid, string locid)
        {
            try
            {
                //查询TrSn
                Dictionary <string, object> dic = new Dictionary <string, object>();
                dic.Add("stock_out_no", woid);
                dic.Add("loc_id", locid);
                dic.Add("status", "2");

                SearchRInventoryDetail sb = new SearchRInventoryDetail(dic);
                sb.ExecuteQuery();
                DataTable dt = sb.GetResult();

                if (dt == null || dt.Rows.Count == 0)
                {
                    return(null);
                }

                List <string> listTrSn = new List <string>();
                foreach (DataRow dr in dt.Rows)
                {
                    listTrSn.Add(dr["TR_SN"].ToString());
                }

                return(listTrSn);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
コード例 #3
0
        private void HolderFrm_DoubleClick(object sender, EventArgs e)
        {
            try
            {
                //MessageBox.Show("ID:" + label_Id.Text);
                if (string.IsNullOrEmpty(MyData.GetStockNo().Trim()))
                {
                    MessageBox.Show("请先填入入库单等信息");
                    return;
                }

                //根据周转箱查询储位信息
                Dictionary <string, object> dic = new Dictionary <string, object>();
                dic.Add("holder_id", label_Id.Text);
                dic.Add("stock_no", MyData.GetStockNo());
                SearchRHolderLocidRelationShip sl = new SearchRHolderLocidRelationShip(dic);
                sl.ExecuteQuery();
                DataTable dt = sl.GetResult();
                if (dt == null || dt.Rows.Count == 0)
                {
                    ShowHint("在Holder表中查不到该周转箱信息", Color.Red);
                    return;
                }
                if (string.IsNullOrEmpty(dt.Rows[0]["loc_id"].ToString().Trim()))
                {
                    ShowHint("在Holder表中查不到该周转箱的储位信息", Color.Red);
                    return;
                }

                //根据储位查询物料条码信息
                dic.Clear();
                dic.Add("status", 0);
                dic.Add("loc_id", dt.Rows[0]["loc_id"].ToString().Trim());
                SearchRInventoryDetail sr = new SearchRInventoryDetail(dic);
                sr.ExecuteQuery();
                dt = sr.GetResult();
                if (dt == null || dt.Rows.Count == 0)
                {
                    ShowHint("在R_Inventory_Detail表中查不到该储位信息", Color.Red);
                    return;
                }

                //显示
                string str = "";
                int    cnt = 0;
                foreach (DataRow dr in dt.Rows)
                {
                    str += dr["tr_sn"].ToString() + ",   ";
                    cnt++;
                }

                ShowHint("周转箱: " + label_Id.Text + "  中已装入 " + cnt.ToString() + " 盘物料,条码信息如下: \r\n" + str, Color.Red);
            }
            catch (Exception ex)
            {
                ShowHint(ex.Message, Color.Red);
            }
        }
コード例 #4
0
ファイル: SplitMaterial.cs プロジェクト: 88886/WMS_Client
        private DataTable GetTrSnInfo(string trSn)
        {
            Dictionary <string, object> dic = new Dictionary <string, object>();
            DataTable dt = new DataTable();

            try
            {
                dic.Add("tr_sn", trSn);
                SearchRInventoryDetail sr = new SearchRInventoryDetail(dic);
                sr.ExecuteQuery();
                dt = sr.GetResult();
                if (dt == null || dt.Rows.Count == 0)
                {
                    ShowHint("在r_inventory_detail表中查询不到该trSn:" + trSn, Color.Red);
                    return(null);
                }

                if (string.IsNullOrEmpty(dt.Rows[0]["KP_NO"].ToString()))
                {
                    ShowHint("该TrSn" + trSn + "在r_inventory_detail表中的料号为空!", Color.Red);
                    return(null);
                }
            }
            catch (Exception ex)
            {
                ShowHint("GetDataInfoByTrSn: " + ex.Message, Color.Red);
                return(null);
            }

            try
            {
                dic.Clear();

                dic.Add("material_no", dt.Rows[0]["KP_NO"].ToString());
                SearchBMaterial sb = new SearchBMaterial(dic);
                sb.ExecuteQuery();
                DataTable dt2 = sb.GetResult();

                dt.Rows[0]["KP_DESC"] = dt2.Rows[0]["material_desc"];

                if (string.IsNullOrEmpty(dt.Rows[0]["KP_DESC"].ToString().Trim()))
                {
                    ShowHint("料号:" + dt.Rows[0]["KP_NO"].ToString() + "在b_material中的物料描述为空!", Color.Red);
                    return(null);
                }
            }
            catch (Exception ex)
            {
                ShowHint("SearchBMaterial: " + ex.Message, Color.Red);
                return(null);
            }

            return(dt);
        }
コード例 #5
0
        public static DataTable SearchFromRInventoryDetailByTrSn(string trsn)
        {
            try
            {
                Dictionary <string, object> dic = new Dictionary <string, object>();
                dic.Add("tr_sn", trsn);

                SearchRInventoryDetail sb = new SearchRInventoryDetail(dic);
                sb.ExecuteQuery();

                return(sb.GetResult());
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
コード例 #6
0
        private DataTable GetDataInfoByTrSn(string trsn)
        {
            Dictionary <string, object> dic = new Dictionary <string, object>();
            DataTable dt = new DataTable();

            try
            {
                dic.Add("tr_sn", trsn);
                SearchRInventoryDetail sr = new SearchRInventoryDetail(dic);
                sr.ExecuteQuery();
                dt = sr.GetResult();
                if (dt == null || dt.Rows.Count == 0)
                {
                    return(null);
                }

                if (string.IsNullOrEmpty(dt.Rows[0]["KP_NO"].ToString()))
                {
                    return(null);
                }
            }
            catch (Exception ex)
            {
                ShowHint("SearchRInventoryDetail: " + trsn + ", " + ex.Message, Color.Red);
                return(null);
            }

            try
            {
                dic.Clear();

                dic.Add("material_no", dt.Rows[0]["KP_NO"].ToString());
                SearchBMaterial sb = new SearchBMaterial(dic);
                sb.ExecuteQuery();
                DataTable dt2 = sb.GetResult();

                dt.Rows[0]["KP_DESC"] = dt2.Rows[0]["material_desc"];

                return(dt);
            }
            catch (Exception ex)
            {
                ShowHint("SearchBMaterial: " + ex.Message, Color.Red);
                return(null);
            }
        }
コード例 #7
0
        private void UpdateStockCountData(string locid)
        {
            try
            {
                //查询TrSn
                Dictionary <string, object> dic = new Dictionary <string, object>();

                dic.Add("loc_id", locid);
                dic.Add("status", "1");

                SearchRInventoryDetail sb = new SearchRInventoryDetail(dic);
                sb.ExecuteQuery();
                DataTable dt = sb.GetResult();

                if (dt == null || dt.Rows.Count == 0)
                {
                    label_pd_kpno.Text    = "";
                    label_pd_qty.Text     = "";
                    label_pd_count.Text   = "";
                    label_pd_plant.Text   = "";
                    label_pd_stockid.Text = "";
                    dataGridView_stockcount.Rows.Clear();
                    return;
                }

                label_pd_kpno.Text    = dt.Rows[0]["KP_NO"].ToString();
                label_pd_plant.Text   = dt.Rows[0]["PLANT"].ToString();
                label_pd_stockid.Text = dt.Rows[0]["STOCK_ID"].ToString();

                int qty   = 0;
                int count = 0;
                dataGridView_stockcount.Rows.Clear();
                try
                {
                    foreach (DataRow dr in dt.Rows)
                    {
                        count++;
                        qty += int.Parse(dr["QTY"].ToString());
                        dataGridView_stockcount.Rows.Add(false,
                                                         count.ToString(),
                                                         dr["TR_SN"].ToString(),
                                                         dr["DATE_CODE"].ToString(),
                                                         dr["QTY"].ToString());
                    }

                    label_pd_qty.Text   = qty.ToString();
                    label_pd_count.Text = count.ToString();
                    dataGridView_stockcount.ClearSelection();
                }
                catch (Exception ex)
                {
                    ShowHint(ex.Message, Color.Red);
                    return;
                }
            }
            catch (Exception ex)
            {
                ShowHint(ex.Message, Color.Red);
                return;
            }
        }
コード例 #8
0
ファイル: Program.cs プロジェクト: 88886/ScanMaterial
        static void Run()
        {
            try
            {
                Log.Debug(DateTime.Now.ToString() + " 启动运行物料过期扫描软件...");
                Trace.WriteLine(DateTime.Now.ToString() + " 启动运行物料过期扫描软件...");
                Console.WriteLine(DateTime.Now.ToString() + " 启动运行物料过期扫描软件...");

                //查询物料明细表
                Dictionary <string, object> dic = new Dictionary <string, object>();
                DataTable dt            = new DataTable();
                string    dateCode      = string.Empty;
                string    fifoDC        = string.Empty;
                string    message       = string.Empty;
                int       userdate      = 0;
                int       usedate_delay = 0;
                try
                {
                    dic.Add("status", "1"); //在库明细查询
                    SearchRInventoryDetail sr = new SearchRInventoryDetail(dic);
                    sr.ExecuteQuery();
                    dt = sr.GetResult();
                    if (dt == null || dt.Rows.Count == 0)
                    {
                        message = "异常:SearchRInventoryDetail结果集为空!";
                        Console.WriteLine(message);
                        Trace.WriteLine(message);
                        Log.Error(message);
                        return;
                    }
                }
                catch (Exception ex)
                {
                    message = "异常:SearchRInventoryDetail: " + ex.Message;
                    Console.WriteLine(message);
                    Trace.WriteLine(message);
                    Log.Error(message);
                    return;
                }

                cntTotal = dt.Rows.Count;
                message  = "共查询到:" + cntTotal + " 条记录!";
                Console.WriteLine(message);
                Trace.WriteLine(message);
                Log.Error(message);

                int i = 0;
                foreach (DataRow dr in dt.Rows)
                {//根据物料明细,查询基础表,获取使用期限,物料等级等信息
                    i++;
                    //if (i == 100)
                    //{
                    //    break;
                    //}
                    //物料唯一条码,料号,周期非空判断
                    if (string.IsNullOrEmpty(dr["TR_SN"].ToString().Trim()) ||
                        string.IsNullOrEmpty(dr["KP_NO"].ToString().Trim()) ||
                        string.IsNullOrEmpty(dr["DATE_CODE"].ToString().Trim())
                        )
                    {
                        cntException++;
                        message = "异常:NO=" + i + ", 信息不全,TR_SN=" + dr["TR_SN"].ToString().Trim() +
                                  ", KP_NO=" + dr["KP_NO"].ToString().Trim() +
                                  ", DATE_CODE=" + dr["DATE_CODE"].ToString().Trim();
                        Console.WriteLine(message);
                        Trace.WriteLine(message);
                        Log.Error(message);
                        continue;
                    }
                    dateCode = dr["DATE_CODE"].ToString().Trim();
                    fifoDC   = DataCodeProcess.fifo_datecode(dateCode.ToUpper().Trim());

                    try
                    {
                        //查询使用期限,延长期限
                        dic.Clear();
                        dic.Add("material_no", dr["KP_NO"].ToString().Trim());
                        SearchBMaterial sb = new SearchBMaterial(dic);
                        sb.ExecuteQuery();
                        DataTable dt2 = sb.GetResult();
                        if (dt2 == null || dt.Rows.Count == 0)
                        {
                            cntException++;
                            message = "异常:NO=" + i + ", 查询使用期限失败, KP_NO=" + dr["KP_NO"].ToString().Trim();
                            Console.WriteLine(message);
                            Trace.WriteLine(message);
                            Log.Error(message);
                            continue;
                        }

                        if (string.IsNullOrEmpty(dt2.Rows[0]["material_level"].ToString().Trim()) ||
                            string.IsNullOrEmpty(dt2.Rows[0]["user_date"].ToString().Trim()))
                        {
                            cntException++;
                            message = "异常:NO=" + i + ", KP_NO=" + dr["KP_NO"].ToString().Trim() + "的物料等级或者使用期限为空, Level=" +
                                      dt2.Rows[0]["material_level"].ToString().Trim() + ", USER_DATE=" + dt2.Rows[0]["user_date"].ToString().Trim();
                            Console.WriteLine(message);
                            Trace.WriteLine(message);
                            Log.Error(message);
                            continue;
                        }

                        //如果物料等级为2,需要更新算法
                        if (dt2.Rows[0]["material_level"].ToString().Trim().Equals("2"))
                        {
                            fifoDC = DataCodeProcess.GetFirstDayOfMonth(fifoDC);
                        }

                        //使用期限从字符串转为int型
                        userdate = 0;
                        if (!Int32.TryParse(dt2.Rows[0]["user_date"].ToString().Trim(), out userdate))
                        {
                            cntException++;
                            message = "异常:NO=" + i + ", 使用期限转化为int失败, KP_NO=" + dr["KP_NO"].ToString().Trim() + ", USER_DATE=" + dt2.Rows[0]["user_date"].ToString().Trim();
                            Console.WriteLine(message);
                            Trace.WriteLine(message);
                            Log.Error(message);
                            continue;
                        }
                        if (!string.IsNullOrEmpty(dt2.Rows[0]["usedate_delay"].ToString().Trim()))
                        {
                            if (!Int32.TryParse(dt2.Rows[0]["usedate_delay"].ToString().Trim(), out usedate_delay))
                            {
                                cntException++;
                                message = "异常:NO=" + i + ", 延长期限转化为int失败, KP_NO=" + dr["KP_NO"].ToString().Trim() + ", USEDATE_DELAY=" + dt2.Rows[0]["usedate_delay"].ToString().Trim();
                                Console.WriteLine(message);
                                Trace.WriteLine(message);
                                Log.Error(message);
                                usedate_delay = 0; //continue;
                            }
                        }

                        //比较是否过期
                        int year       = (userdate + usedate_delay) / 360;
                        int month      = (userdate + usedate_delay) % 360 / 30;
                        int day        = (userdate + usedate_delay) % 30;
                        int fifoDay    = 0;
                        int CurrentDay = DateTime.Now.Year * 10000 + DateTime.Now.Month * 100 + DateTime.Now.Day;
                        if (!Int32.TryParse(fifoDC, out fifoDay))
                        {
                            cntException++;
                            message = "异常:NO=" + i + ", fifoDC转换成Int失败: fifoDC=" + fifoDC;
                            Console.WriteLine(message);
                            Trace.WriteLine(message);
                            Log.Error(message);
                            continue;
                        }

                        fifoDay = fifoDay + year * 10000 + month * 100 + day;
                        message = "NO=" + i + ", TR_SN=" + dr["TR_SN"].ToString().Trim() +
                                  ", KP_NO=" + dr["KP_NO"].ToString().Trim() +
                                  ", DateCode=" + dateCode +
                                  ", fifoDC=" + fifoDC +
                                  ", UserDate=" + userdate.ToString() +
                                  ", UseDate_Delay=" + usedate_delay.ToString() +
                                  ", 过期时间=" + fifoDay.ToString() +
                                  ", 当前时间=" + CurrentDay.ToString();
                        Trace.WriteLine(message);
                        if (fifoDay < CurrentDay)
                        {
                            cntGuoQi++;
                            Console.WriteLine(message);
                            Log.Error("物料过期:NO=" + i + ", " + message);

                            //将过期的物料状态从1更新为5
                            try
                            {
                                UpdateRInventoryDetailStatus ur = new UpdateRInventoryDetailStatus(dr["TR_SN"].ToString().Trim(), "1", "5");
                                ur.ExecuteUpdate();
                            }
                            catch (Exception ex)
                            {
                                cntException++;
                                message = "UpdateRInventoryDetailStatus: " + ex.Message;
                                Console.WriteLine("异常:" + ex.Message);
                                Trace.WriteLine("异常:" + ex.Message);
                                Log.Error("异常:" + ex.Message);
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine("异常:" + ex.Message);
                        Trace.WriteLine("异常:" + ex.Message);
                        Log.Error("异常:" + ex.Message);
                        continue;
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("异常:" + ex.Message);
                Trace.WriteLine("异常:" + ex.Message);
                Log.Error("异常:" + ex.Message);
            }
            finally
            {
                Console.WriteLine(DateTime.Now.ToString() + " 结束运行物料过期扫描软件!");
                Trace.WriteLine(DateTime.Now.ToString() + " 结束运行物料过期扫描软件!");
                Log.Debug(DateTime.Now.ToString() + " 结束运行物料过期扫描软件!");
            }
        }
コード例 #9
0
        private void textBox_trsn_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode != Keys.Enter)
            {
                return;
            }

            if (string.IsNullOrEmpty(textBox_trsn.Text))
            {
                ShowHint("请先输入单号", Color.Red);
                return;
            }

            DataTable dt = new DataTable();
            Dictionary <string, object> dic = new Dictionary <string, object>();

            try
            {
                dic.Add("stock_no", textBox_trsn.Text);
                dic.Add("stockno_type", 8);

                SearchRInventoryId sr = new SearchRInventoryId(dic);
                sr.ExecuteQuery();
                dt = sr.GetResult();
                if (dt == null || dt.Rows.Count == 0)
                {
                    ShowHint("在R_Inventory_Id中查询不到该工单或者该工单类型为7,无数据需要删除", Color.Lime);
                    return;
                }
            }
            catch (Exception ex)
            {
                ShowHint("SearchRInventoryId:" + ex.Message, Color.Red);
                return;
            }

            try
            {
                dic.Clear();
                dic.Add("stock_no", textBox_trsn.Text);
                //dic.Add("stock_out_no", "");
                dic.Add("status", "1");

                SearchRInventoryDetail sd = new SearchRInventoryDetail(dic);
                sd.ExecuteQuery();
                dt = sd.GetResult();

                if (dt == null || dt.Rows.Count == 0)
                {
                    ShowHint("该工单无数据需要推送", Color.Lime);
                    return;
                }
            }
            catch (Exception ex)
            {
                ShowHint("SearchRInventoryDetail:" + ex.Message, Color.Red);
                return;
            }


            Print("共需要推送:" + dt.Rows.Count + " 条数据!");
            foreach (DataRow dr in dt.Rows)
            {
                if (!string.IsNullOrEmpty(dr["tr_sn"].ToString()))
                {
                    try
                    {
                        if (Phicomm_WMS.OUTIO.tR_Tr_Sn.DelTrSn(dr["tr_sn"].ToString()))
                        {
                            Print("删除TrSn=" + dr["tr_sn"].ToString() + " 的线边仓信息成功!");
                        }
                    }
                    catch (Exception ex)
                    {
                        Print("TrSn=" + dr["tr_sn"].ToString() + ", " + ex.Message);
                    }
                }
            }

            Print("删除完毕");
        }
コード例 #10
0
        private void textBox3_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode != Keys.Enter)
            {
                return;
            }

            if (string.IsNullOrEmpty(textBox3.Text.Trim()))
            {
                MessageBox.Show("库位不能为空!");
                textBox3.Focus();
                return;
            }

            if (string.IsNullOrEmpty(textBox2.Text.Trim()))
            {
                MessageBox.Show("工厂不能为空!");
                textBox2.Focus();
                return;
            }

            if (string.IsNullOrEmpty(textBox1.Text.Trim()))
            {
                MessageBox.Show("盘点日期不能为空!");
                textBox1.Focus();
                return;
            }

            try
            {
                _date     = textBox1.Text.Trim();
                _plant    = textBox2.Text.Trim();
                _stock_id = textBox3.Text.Trim();
                if (_date.Length != 10)
                {
                    MessageBox.Show("长度不对,应为8位");
                    return;
                }
                if (!_date.All(c => (c >= '0' && c <= '9')))
                {
                    MessageBox.Show("输入格式不对,格式必须为:20180608,请重新输入!");
                    return;
                }

                Dictionary <string, object> dic = new Dictionary <string, object>();

                //检查要盘点的信息是否有记录
                dic.Clear();
                dic.Add("plant", _plant);
                dic.Add("stock_id", _stock_id);
                dic.Add("status", "1");
                SearchRInventoryDetail sr = new SearchRInventoryDetail(dic);
                sr.ExecuteQuery();
                DataTable dt = sr.GetResult();
                if (dt == null || dt.Rows.Count == 0)
                {
                    MessageBox.Show("根据工厂和库位查询不到在库物料,请修改盘点条件!");
                    textBox3.Focus();
                    return;
                }

                //检查盘点是否重复
                dic.Clear();
                dic.Add("check_date", _date);
                dic.Add("plant", _plant);
                dic.Add("stock_id", _stock_id);
                SearchInventoryCheckByMaterialNo sc = new SearchInventoryCheckByMaterialNo(dic);
                sc.ExecuteQuery();
                dt = sc.GetResult();
                if (dt != null && dt.Rows.Count > 0)
                {
                    string status = dt.Rows[0]["Status"].ToString();
                    if (status.Equals("1"))
                    {
                        MessageBox.Show("该日期,工厂,库位的条件已经盘点过,请修改盘点信息!");
                        textBox1.Text = "";
                        textBox1.Focus();
                        return;
                    }
                }
                else
                {
                    //插入盘点信息
                    InsertInventoryCheckByMaterialNo ic = new InsertInventoryCheckByMaterialNo(_date, "*", _plant, _stock_id);
                    ic.ExecuteUpdate();
                }

                this.DialogResult = DialogResult.OK;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                textBox1.Text = "";
                textBox1.Focus();
            }
        }