Esempio n. 1
0
        public bool GetTrayInfoByTrayID(Barcode_Model Barcode_Model, ref Tray_Model trayInfo)
        {
            bool IsResult = false;

            DataSet ds;

            string sql = null, errMsg = string.Empty;

            sql = string.Format(@"select TRAYID,TrayNO,qty,materialno,materialdesc,materialstd,serialno,rowno from T_TRAY JOIN T_OUTBARCODE ON T_TRAY.ID=T_OUTBARCODE.TRAYID where T_TRAY.ID={0}", Barcode_Model.TrayID);
            OperationSql.GetDataset(sql, out ds, out errMsg);
            if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
            {
                trayInfo             = TOOL.DataTableToList.DataRowToModel <Tray_Model>(ds.Tables[0].Rows[0]);
                trayInfo.listDetails = new List <TrayDetails_Model>();
                TrayDetails_Model model;
                foreach (DataRow item in ds.Tables[0].Rows)
                {
                    TrayDetails_Model tdm = trayInfo.listDetails.Find(delegate(TrayDetails_Model v)
                    {
                        return(v.cinvcode.ToUpper().Equals(item["materialno"].ToString().ToUpper()) &&
                               (string.IsNullOrEmpty(item["rowno"].ToDBString()) || v.ROWNO.Equals(item["rowno"].ToDBString())));
                    });
                    if (tdm == null)
                    {
                        model          = new TrayDetails_Model();
                        model.Qty      = ObjectExtend.ToDouble(item["qty"]);
                        model.cinvcode = item["materialno"].ToString();
                        model.cinvname = item["materialdesc"].ToString();
                        model.cinvstd  = item["materialstd"].ToString();

                        model.ROWNO       = item["rowno"].ToDBString();
                        model.listBarcode = new List <string>()
                        {
                            item["serialno"].ToString()
                        };
                        trayInfo.listDetails.Add(model);
                    }
                    else
                    {
                        tdm.listBarcode.Add(item["serialno"].ToString());
                        tdm.Qty += ObjectExtend.ToDouble(item["qty"]);
                    }
                }

                IsResult = true;
            }

            return(IsResult);
        }
Esempio n. 2
0
        public bool GetTrayInfoByTrayID2(Barcode_Model Barcode_Model, ref Tray_Model trayInfo)
        {
            bool IsResult = false;

            DataSet ds;

            string sql = null, errMsg = string.Empty;

            sql = string.Format(@"select voucherno,TRAYID,TrayNO,qty,materialno,materialdesc,materialstd,serialno,rowno from T_TRAY JOIN T_OUTBARCODE ON T_TRAY.ID=T_OUTBARCODE.TRAYID where T_TRAY.ID={0}", Barcode_Model.TrayID);
            OperationSql.GetDataset(sql, out ds, out errMsg);
            if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
            {
                ds.Tables[0].Columns.Add("socode", typeof(System.String));
                ds.Tables[0].Columns.Add("sorowno", typeof(System.String));
                //SqlDataReader sqlreader = null;
                //using (SqlConnection conOne = new SqlConnection(OperationSql.U8ConnStr))
                //{
                //    conOne.Open();
                //    SqlCommand command = new SqlCommand();
                //    command.Connection = conOne;
                //    foreach (DataRow item in ds.Tables[0].Rows)
                //    {
                //        sql = string.Format("select ISNULL(ordercode,'') socode,ISNULL(orderseq,'') sorowno from v_st_mom_orderdetail where mocode = '{0}' and MoSeq='{1}'", item["voucherno"].ToDBString(), item["rowno"].ToDBString());
                //        command.CommandText = sql;
                //        sqlreader = command.ExecuteReader();
                //        if (sqlreader.Read())
                //        {
                //            item["socode"] = sqlreader["socode"].ToDBString();
                //            item["sorowno"] = sqlreader["sorowno"].ToDBString();
                //        }
                //        if (sqlreader != null && !sqlreader.IsClosed)
                //            sqlreader.Close();
                //    }
                //}
                trayInfo             = TOOL.DataTableToList.DataRowToModel <Tray_Model>(ds.Tables[0].Rows[0]);
                trayInfo.listDetails = new List <TrayDetails_Model>();
                TrayDetails_Model model;
                foreach (DataRow item in ds.Tables[0].Rows)
                {
                    TrayDetails_Model tdm = trayInfo.listDetails.Find(delegate(TrayDetails_Model v)
                    {
                        return(v.cinvcode.ToUpper().Equals(item["materialno"].ToString().ToUpper()) &&
                               (string.IsNullOrEmpty(item["sorowno"].ToDBString()) || item["sorowno"].ToDBString().Equals("0") || v.SOROWNO.Equals(item["sorowno"].ToDBString())));
                    });
                    if (tdm == null)
                    {
                        model          = new TrayDetails_Model();
                        model.Qty      = ObjectExtend.ToDouble(item["qty"]);
                        model.cinvcode = item["materialno"].ToString();
                        model.cinvname = item["materialdesc"].ToString();
                        model.cinvstd  = item["materialstd"].ToString();

                        model.SOROWNO     = item["sorowno"].ToDBString();
                        model.listBarcode = new List <string>()
                        {
                            item["serialno"].ToString()
                        };
                        trayInfo.listDetails.Add(model);
                    }
                    else
                    {
                        tdm.listBarcode.Add(item["serialno"].ToString());
                        tdm.Qty += ObjectExtend.ToDouble(item["qty"]);
                    }
                }

                IsResult = true;
            }

            return(IsResult);
        }
Esempio n. 3
0
        public bool GetTrayInfoByTrayIDForOutStock(Barcode_Model Barcode_Model, ref Tray_Model trayInfo)
        {
            bool           IsResult   = false;
            string         connString = OperationSql.ERPConnStr;
            DataSet        ds         = new DataSet();
            string         errMsg     = "";
            SqlCommand     view       = new SqlCommand();
            SqlCommand     cmd        = new SqlCommand();
            SqlConnection  conn       = new SqlConnection();
            SqlDataAdapter adp        = new SqlDataAdapter();

            conn.ConnectionString = connString;
            try
            {
                conn.Open();
            }
            catch (Exception ex)
            {
                errMsg = ex.Message;
                return(false);
            }
            cmd.Connection = conn;

            string sqlHead = string.Format(@"select ISNULL(orderseq,'') sorowno,TRAYID,TrayNO,bar.qty,materialno,serialno
FROM  ITSV.Barcode.DBO.T_TRAY tray join ITSV.Barcode.DBO.T_OUTBARCODE bar  ON tray.ID=bar.TRAYID
left JOIN v_st_mom_orderdetail m ON m.MoSeq=bar.rowno and bar.voucherno=m.MoCode where 1=1 and tray.ID={0}", Barcode_Model.TrayID);
            string WMSdbserver = "", WMSdbuser = "", WMSdbpwd = "";
            string tmp  = OperationSql.connectionString;
            string tmp1 = "";

            tmp1        = tmp.Substring(tmp.IndexOf("Data Source="));
            WMSdbserver = tmp1.Substring(12, tmp1.IndexOf(";") - 12);
            tmp1        = tmp.Substring(tmp.IndexOf("UID="));
            WMSdbuser   = tmp1.Substring(4, tmp1.IndexOf(";") - 4);
            tmp1        = tmp.Substring(tmp.IndexOf("Pwd="));
            WMSdbpwd    = tmp1.Substring(4, tmp1.Length - 4);

            string CreatelinkServer = "";

            CreatelinkServer = (@"if exists(select 1 from master.dbo.sysservers where srvname='ITSV')
begin
    EXEC sp_dropserver 'ITSV','droplogins' 
end   
exec sp_addlinkedserver   'ITSV', '', 'SQLOLEDB ', '" + WMSdbserver + @"'; 
exec sp_addlinkedsrvlogin 'ITSV', 'false ',null, '" + WMSdbuser + "', '" + WMSdbpwd + @"' ;");

            DataTable dt1 = new DataTable("head");

            ds.Tables.Add(dt1);

            try
            {
                cmd.CommandText = CreatelinkServer;
                cmd.ExecuteNonQuery();
                cmd.CommandText   = sqlHead;
                adp.SelectCommand = cmd;
                adp.Fill(ds.Tables["head"]);

                if (ds.Tables["head"].Rows.Count < 1)
                {
                    errMsg = "生产订单不存在或状态不正确!";
                    return(false);
                }
                if (ds != null && ds.Tables.Count > 0 && ds.Tables["head"].Rows.Count > 0)
                {
                    trayInfo             = TOOL.DataTableToList.DataRowToModel <Tray_Model>(ds.Tables[0].Rows[0]);
                    trayInfo.listDetails = new List <TrayDetails_Model>();
                    TrayDetails_Model model;
                    foreach (DataRow item in ds.Tables["head"].Rows)
                    {
                        TrayDetails_Model tdm = trayInfo.listDetails.Find(delegate(TrayDetails_Model v)
                        {
                            return(v.cinvcode.ToUpper().Equals(item["materialno"].ToString().ToUpper()) &&
                                   (string.IsNullOrEmpty(item["sorowno"].ToDBString()) || item["sorowno"].ToDBString().Equals("0") || v.SOROWNO.Equals(item["sorowno"].ToDBString())));
                        });
                        if (tdm == null)
                        {
                            model             = new TrayDetails_Model();
                            model.Qty         = ObjectExtend.ToDouble(item["qty"]);
                            model.cinvcode    = item["materialno"].ToString();
                            model.SOROWNO     = item["sorowno"].ToDBString();
                            model.listBarcode = new List <string>()
                            {
                                item["serialno"].ToString()
                            };
                            trayInfo.listDetails.Add(model);
                        }
                        else
                        {
                            tdm.listBarcode.Add(item["serialno"].ToString());
                            tdm.Qty += ObjectExtend.ToDouble(item["qty"]);
                        }
                        IsResult = true;
                    }
                }
                return(IsResult);
            }
            catch (Exception ex)
            {
                errMsg = ex.Message;
                return(false);
            }
            finally
            {
                conn.Close();
            }
        }