Exemplo n.º 1
0
        /// <summary>
        /// 保存时获取产品主键
        /// </summary>
        /// <param name="entities"></param>
        /// <returns></returns>
        public SavedResult <Int64> Save2(IList <QTProductUserModel> entities)
        {
            SavedResult <Int64> savedresult = new SavedResult <Int64>();

            try
            {
                for (var i = 0; i < entities.Count; i++)
                {
                    if (entities[i].ProductBZ != "")
                    {
                        Dictionary <string, object> dic = new Dictionary <string, object>();
                        new CreateCriteria(dic).Add(ORMRestrictions <string> .Eq("ProductBZ", entities[i].ProductBZ));
                        QTProductModel qTProductModel = QTProductFacade.Find(dic).Data[0];
                        entities[i].ProductPhid = qTProductModel.PhId;
                    }
                }
                savedresult = base.Save <Int64>(entities, "");
            }
            catch (Exception ex)
            {
                savedresult.Status = ResponseStatus.Error;
                savedresult.Msg    = ex.Message.ToString();
            }
            return(savedresult);
        }
Exemplo n.º 2
0
        /// <summary>
        /// 获取产品用户通过产品标识和G6账号
        /// </summary>
        /// <param name="ProductBZ"></param>
        /// <param name="UserNo"></param>
        /// <returns></returns>
        public QTProductUserModel getUserByProduct(string ProductBZ, string UserNo)
        {
            Dictionary <string, object> dic = new Dictionary <string, object>();

            new CreateCriteria(dic).Add(ORMRestrictions <string> .Eq("ProductBZ", ProductBZ))
            .Add(ORMRestrictions <string> .Eq("Fg3userno", UserNo));
            var Dygx = QTProductUserDygxFacade.Find(dic).Data;

            if (Dygx.Count > 0)
            {
                Dictionary <string, object> dic2 = new Dictionary <string, object>();
                new CreateCriteria(dic2).Add(ORMRestrictions <string> .Eq("ProductBZ", ProductBZ))
                .Add(ORMRestrictions <string> .Eq("ProductUserCode", Dygx[0].ProductUserCode));
                var ProductUser = base.Find(dic2).Data;
                if (ProductUser.Count > 0)
                {
                    Dictionary <string, object> dic3 = new Dictionary <string, object>();
                    new CreateCriteria(dic3).Add(ORMRestrictions <string> .Eq("ProductBZ", ProductBZ));
                    IList <QTProductModel> qTProductModelList = QTProductFacade.Find(dic3).Data;
                    if (qTProductModelList.Count > 0)
                    {
                        QTProductModel qTProductModel = qTProductModelList[0];
                        string         conn;
                        string         sqltext = "SELECT " + qTProductModel.FSqlUserTablePwd + " FROM " + qTProductModel.FSqlUserTable + " WHERE " + qTProductModel.FSqlUserTableCode + "='" + ProductUser[0].ProductUserCode + "'";
                        if (qTProductModel.FSqlType == "oracle")
                        {
                            conn = "ConnectType=ORACLEClient;Data Source=" + qTProductModel.FSqlServer + ";User ID=" + qTProductModel.FSqlDataName + ";Password="******";";
                        }
                        else
                        {
                            conn = "ConnectType=SqlClient;Server=" + qTProductModel.FSqlServer + ";Database=" + qTProductModel.FSqlSource + ";User ID =" + qTProductModel.FSqlDataName + "; Password="******";";
                        }
                        DbHelper.Open(conn);
                        DataTable dataTable = DbHelper.GetDataTable(conn, sqltext);
                        DbHelper.Close(conn);
                        if (dataTable.Rows.Count > 0)
                        {
                            ProductUser[0].ProductUserPwd = dataTable.Rows[0][qTProductModel.FSqlUserTablePwd].ToString();
                        }
                    }

                    return(ProductUser[0]);
                }
                else
                {
                    return(null);
                }
            }
            else
            {
                return(null);
            }
        }