Пример #1
0
        public static Guid TransferSetId(string old)
        {
            try
            {
                Guid result = Guid.Empty;

                RelationSqlServerUtility rsql = new RelationSqlServerUtility();

                string strsql = "select distinct new from Rset where old='{0}'";

                DataSet ds = rsql.ExecuteSqlDataSet(string.Format(strsql, old));

                if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0 && ds.Tables[0].Columns.Count > 0)
                {
                    result = new Guid(ds.Tables[0].Rows[0][0].ToString());
                }

                return result;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Пример #2
0
        /// <summary>
        ///  而且要添加ExpertFirld 
        /// </summary>
        public static void TransferUserFieldRelation(string old, Guid userid)
        {
            Guid result = Guid.Empty;

            RelationSqlServerUtility rsql = new RelationSqlServerUtility();

            DataSet ds = rsql.ExecuteSqlDataSet(string.Format("select new from RFieldForUserNLab where old='{0}'", old));

            if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
            {
                result = new Guid(ds.Tables[0].Rows[0][0].ToString());
            }

            CY.CSTS.Core.Business.ExpertField expertfield = new CY.CSTS.Core.Business.ExpertField();

            expertfield.FieldID = result;
            expertfield.ExpertID = userid;

            expertfield.Save();
        }
Пример #3
0
        protected void import_Click(object sender, EventArgs e)
        {
            CY.Utility.DBUtility.ImportSqlServerUtility isql = new CY.Utility.DBUtility.ImportSqlServerUtility();

            string strsql = "select * from PERSONNEL";

            DataSet ds = isql.ExecuteSqlDataSet(strsql);

            RelationSqlServerUtility rsql = new RelationSqlServerUtility();

            string Rsql = "select * from RUser";

            DataSet dsR = rsql.ExecuteSqlDataSet(Rsql);

            Rsql = "select * from RLab";

            DataSet dsRLab = rsql.ExecuteSqlDataSet(Rsql);

            //List<CY.CSTS.Core.Business.Lab> listLab = CY.CSTS.Core.Business.Lab.GetAllLab() as List<CY.CSTS.Core.Business.Lab>;

            if (dsRLab != null && dsRLab.Tables.Count > 0 && dsRLab.Tables[0].Rows.Count > 0 && dsRLab.Tables[0].Columns.Count > 0)
            {
                for (int i = 0; i < dsRLab.Tables[0].Rows.Count; i++)
                {

                    strsql = "select * from LABORATORY where LABID = " + dsRLab.Tables[0].Rows[i][0].ToString();

                    DataSet dsLab = isql.ExecuteSqlDataSet(strsql);

                    if (dsLab != null && dsLab.Tables.Count > 0 && dsLab.Tables[0].Rows.Count > 0 && dsLab.Tables[0].Columns.Count > 0)
                    {
                        string strLeadUserID = "0";
                        string strLinkUserID = "0";
                        if (dsLab.Tables[0].Rows[0]["LEAD"] != null)
                        {
                             strLeadUserID = dsLab.Tables[0].Rows[0]["LEAD"].ToString();
                        }
                        if (dsLab.Tables[0].Rows[0]["LINKMAN"] != null)
                        {
                             strLinkUserID = dsLab.Tables[0].Rows[0]["LINKMAN"].ToString();
                        }

                        if (strLeadUserID == "")
                        {
                            strLeadUserID = "0";
                        }
                        if (strLinkUserID == "")
                        {
                            strLinkUserID = "0";
                        }

                        strsql = "select * from PERSONNEL where PERSONNELID = " + strLeadUserID;

                        DataSet dsLabLeadP = isql.ExecuteSqlDataSet(strsql);

                        strsql = "select * from PERSONNEL where PERSONNELID = " + strLinkUserID;

                        DataSet dsLabLinkP = isql.ExecuteSqlDataSet(strsql);
                        string leadName = "";
                        string linkName = "";
                        if (dsLabLeadP != null && dsLabLeadP.Tables.Count > 0 && dsLabLeadP.Tables[0].Rows.Count > 0 && dsLabLeadP.Tables[0].Columns.Count > 0)
                        {
                            leadName = dsLabLeadP.Tables[0].Rows[0]["NAME"].ToString();
                        }
                        if (dsLabLinkP != null && dsLabLinkP.Tables.Count > 0 && dsLabLinkP.Tables[0].Rows.Count > 0 && dsLabLinkP.Tables[0].Columns.Count > 0)
                        {
                            linkName = dsLabLinkP.Tables[0].Rows[0]["NAME"].ToString();
                        }

                        if (CY.Utility.Common.StringHelper.IsGuid(dsRLab.Tables[0].Rows[i][1].ToString()))
                        {
                            Guid LabId = new Guid(dsRLab.Tables[0].Rows[i][1].ToString());
                            CY.CSTS.Core.Business.Lab lab = CY.CSTS.Core.Business.Lab.Load(LabId);
                            if (lab != null)
                            {
                                lab.LabPrincipal = leadName;
                                lab.LinkMan = linkName;
                                lab.Save();
                            }
                        }

                    }
                }
            }
        }
Пример #4
0
        protected void import_Machine_LinkMan_Click(object sender, EventArgs e)
        {
            CY.Utility.DBUtility.ImportSqlServerUtility isql = new CY.Utility.DBUtility.ImportSqlServerUtility();

            RelationSqlServerUtility rsql = new RelationSqlServerUtility();

            string Rsql = "select * from RSet";

            DataSet dsRSet = rsql.ExecuteSqlDataSet(Rsql);

            if (dsRSet != null && dsRSet.Tables.Count > 0 && dsRSet.Tables[0].Rows.Count > 0 && dsRSet.Tables[0].Columns.Count > 0)
            {
                for (int i = 0; i < dsRSet.Tables[0].Rows.Count; i++)
                {
                    string strsql = "select * from MACHINESET where SETID = " + dsRSet.Tables[0].Rows[i][0].ToString();

                    DataSet dsSet = isql.ExecuteSqlDataSet(strsql);

                    string strLinkID = "0";
                    if (dsSet != null && dsSet.Tables.Count > 0 && dsSet.Tables[0].Rows.Count > 0 && dsSet.Tables[0].Columns.Count > 0)
                    {
                        strLinkID = dsSet.Tables[0].Rows[0]["LINKMAN"].ToString();
                    }
                    if (strLinkID == "")
                    {
                        strLinkID = "0";
                    }

                    strsql = "select * from PERSONNEL where PERSONNELID = " + strLinkID;

                    DataSet dsLabLinkP = isql.ExecuteSqlDataSet(strsql);

                    string linkName = "";

                    if (dsLabLinkP != null && dsLabLinkP.Tables.Count > 0 && dsLabLinkP.Tables[0].Rows.Count > 0 && dsLabLinkP.Tables[0].Columns.Count > 0)
                    {
                        linkName = dsLabLinkP.Tables[0].Rows[0]["NAME"].ToString();
                    }

                    if (CY.Utility.Common.StringHelper.IsGuid(dsRSet.Tables[0].Rows[i][1].ToString()))
                    {
                        Guid SetId = new Guid(dsRSet.Tables[0].Rows[i][1].ToString());
                        CY.CSTS.Core.Business.MACHINESET set = CY.CSTS.Core.Business.MACHINESET.Load(SetId);
                        if (set != null)
                        {
                            set.LINKMAN = linkName;
                            set.Save();
                        }
                    }

                }
            }
        }
Пример #5
0
        protected void import_Machine_Click(object sender, EventArgs e)
        {
            CY.Utility.DBUtility.ImportSqlServerUtility isql = new CY.Utility.DBUtility.ImportSqlServerUtility();

            string strsql = "select * from INSTRUMENT";

            DataSet ds = isql.ExecuteSqlDataSet(strsql);

            RelationSqlServerUtility rsql = new RelationSqlServerUtility();

            string Rsql = "select * from RInstrument";

            DataSet dsR = rsql.ExecuteSqlDataSet(Rsql);

            Rsql = "select * from RInstrument";

            DataSet dsRLab = rsql.ExecuteSqlDataSet(Rsql);

            //List<CY.CSTS.Core.Business.INSTRUMENT> listLab = CY.CSTS.Core.Business.INSTRUMENT.GetAllINSTRUMENT() as List<CY.CSTS.Core.Business.INSTRUMENT>;

            if (dsRLab != null && dsRLab.Tables.Count > 0 && dsRLab.Tables[0].Rows.Count > 0 && dsRLab.Tables[0].Columns.Count > 0)
            {
                for (int i = 0; i < dsRLab.Tables[0].Rows.Count; i++)
                {

                    strsql = "select * from INSTRUMENT where INSTRUMENTID = " + dsRLab.Tables[0].Rows[i][0].ToString();

                    DataSet dsLab = isql.ExecuteSqlDataSet(strsql);

                    if (dsLab != null && dsLab.Tables.Count > 0 && dsLab.Tables[0].Rows.Count > 0 && dsLab.Tables[0].Columns.Count > 0)
                    {
                        string oldMID = "0";
                        if (dsLab.Tables[0].Rows[0]["SETID"] != null)
                        {
                            oldMID = dsLab.Tables[0].Rows[0]["SETID"].ToString();
                        }

                        if (oldMID == "")
                        {
                            oldMID = "0";
                        }

                        strsql = "select * from RSet where old = " + oldMID;

                        DataSet dsRSet = rsql.ExecuteSqlDataSet(strsql);

                        string strMID = "";
                        if (dsRSet != null && dsRSet.Tables.Count > 0 && dsRSet.Tables[0].Rows.Count > 0 && dsRSet.Tables[0].Columns.Count > 0)
                        {
                            strMID = dsRSet.Tables[0].Rows[0][1].ToString();

                            if (CY.Utility.Common.StringHelper.IsGuid(strMID))
                            {
                                Guid MId = new Guid(strMID);

                                if (CY.CSTS.Core.Business.MACHINESET.Load(MId) != null)
                                {

                                    if (CY.Utility.Common.StringHelper.IsGuid(dsRLab.Tables[0].Rows[i][1].ToString()))
                                    {
                                        Guid IId = new Guid(dsRLab.Tables[0].Rows[i][1].ToString());
                                        CY.CSTS.Core.Business.INSTRUMENT instrument = CY.CSTS.Core.Business.INSTRUMENT.Load(IId);
                                        if (instrument != null)
                                        {
                                            instrument.MachineGroupId = MId;
                                            instrument.Save();
                                        }
                                    }
                                }
                            }
                        }

                    }
                }
            }
        }
Пример #6
0
        protected void import_MachineMemeber_Click(object sender, EventArgs e)
        {
            List<CY.CSTS.Core.Business.INSTRUMENT> listInstrument =  CY.CSTS.Core.Business.INSTRUMENT.GetAllINSTRUMENT()
                as List<CY.CSTS.Core.Business.INSTRUMENT>;

            CY.Utility.DBUtility.ImportSqlServerUtility isql = new CY.Utility.DBUtility.ImportSqlServerUtility();

            RelationSqlServerUtility rsql = new RelationSqlServerUtility();

            string Rsql = "select * from RSet";

            DataSet dsRSet = rsql.ExecuteSqlDataSet(Rsql);

            if (dsRSet != null && dsRSet.Tables.Count > 0 && dsRSet.Tables[0].Rows.Count > 0 && dsRSet.Tables[0].Columns.Count > 0)
            {
                for (int i = 0; i < dsRSet.Tables[0].Rows.Count; i++)
                {
                    string strsql = "select * from MACHINESET where SETID = " + dsRSet.Tables[0].Rows[i][0].ToString();

                    DataSet dsSet = isql.ExecuteSqlDataSet(strsql);

                    string[] strSetManID;
                    string strSetMan = "";
                    if (dsSet != null && dsSet.Tables.Count > 0 && dsSet.Tables[0].Rows.Count > 0 && dsSet.Tables[0].Columns.Count > 0)
                    {
                        strSetMan = dsSet.Tables[0].Rows[0]["SETMAN"].ToString();
                    }
                    if (strSetMan == "")
                    {
                        strSetMan = "0";
                    }
                    if (strSetMan != "0")
                    {
                        strSetManID = strSetMan.Split(',');

                        for (int j = 0; j < strSetManID.Count(); j++)
                        {
                            string strManID = strSetManID[j];
                            int iTemp = 0;
                            if (strManID != "" && int.TryParse(strManID, out iTemp))
                            {
                                //try
                                {
                                    if (CY.Utility.Common.StringHelper.IsGuid(dsRSet.Tables[0].Rows[i][1].ToString()))
                                    {
                                        Guid NewSetID = new Guid(dsRSet.Tables[0].Rows[i][1].ToString());
                                        CY.CSTS.Core.Business.MACHINESET newM = CY.CSTS.Core.Business.MACHINESET.Load(NewSetID);

                                        int usertype = 0;
                                        Guid UintID = new Guid();
                                        if (newM.Unit != null)
                                        {
                                            if (newM.Unit.IsCooperantUnit == 2)
                                            {
                                                usertype = 2;
                                            }
                                            else
                                            {
                                                usertype = 3;
                                            }
                                            UintID = newM.Unit.Id;

                                            strsql = "select * from PERSONNEL where PERSONNELID = " + strManID;

                                           DataSet ds = isql.ExecuteSqlDataSet(strsql);

                                            if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0 && ds.Tables[0].Columns.Count > 0)
                                            {
                                                for (int k = 0; k < ds.Tables[0].Rows.Count; k++)
                                                {
                                                    if (ds.Tables[0].Rows[k][4] != null)
                                                    {
                                                        CY.CSTS.Core.Business.User user = CY.CSTS.Core.Business.User.GetUserByUserId(ds.Tables[0].Rows[k][4].ToString());
                                                        if (user == null)
                                                        {
                                                            user = new CY.CSTS.Core.Business.User();

                                                            user.UnitID = UintID;

                                                            user.UserType = usertype;

                                                            user.Password = "******";

                                                            user.UserID = ds.Tables[0].Rows[k][4].ToString();

                                                            user.Name = ds.Tables[0].Rows[k][4].ToString();

                                                            user.Gender = ds.Tables[0].Rows[k][5].ToString();

                                                            user.BirthDate = !string.IsNullOrEmpty(ds.Tables[0].Rows[k][6].ToString()) ? DateTime.Parse(ds.Tables[0].Rows[k][6].ToString()) : DateTime.MinValue;

                                                            user.EducationID = CY.CSTS.Import.Core.Business.User.TransferEducationId(ds.Tables[0].Rows[k][7].ToString());

                                                            user.PostRankID = CY.CSTS.Import.Core.Business.User.TransferTitltId(ds.Tables[0].Rows[k][8].ToString());

                                                            user.Specialty = ds.Tables[0].Rows[k][9].ToString();

                                                            user.Address = ds.Tables[0].Rows[k][10].ToString();

                                                            user.Mailcode = ds.Tables[0].Rows[k][11].ToString();

                                                            user.Phone = ds.Tables[0].Rows[k][12].ToString();

                                                            user.Fax = ds.Tables[0].Rows[k][13].ToString();

                                                            user.Email = ds.Tables[0].Rows[k][14].ToString();

                                                            user.Resume = ds.Tables[0].Rows[k][15].ToString();

                                                            user.Discourse = ds.Tables[0].Rows[k][20].ToString();

                                                            user.Acquire = ds.Tables[0].Rows[k][21].ToString();

                                                            user.Status = 2;

                                                            user.Remark = ds.Tables[0].Rows[k][25].ToString();

                                                            user.Save();
                                                        }

                                                        List<CY.CSTS.Core.Business.INSTRUMENT> tempListI =
                                                            listInstrument.Where(Items => Items.MachineGroupId == newM.Id).ToList();

                                                        if (tempListI.Count > 0)
                                                        {
                                                            CY.CSTS.Core.Business.MachineGroupMember MMember = new CY.CSTS.Core.Business.MachineGroupMember();
                                                            MMember.InstruID = tempListI[0].Id;
                                                            MMember.UserID = user.Id;
                                                            MMember.MachineGroupID = newM.Id;
                                                            MMember.Save();
                                                        }
                                                    }

                                                }
                                            }
                                        }
                                    }
                                }
                                //catch (Exception ex)
                                //{
                                //    throw ex;
                                //}
                            }
                        }

                    }
                }
            }
        }
Пример #7
0
        private static Guid TransferDomainId(string old)
        {
            Guid result = Guid.Empty;

            RelationSqlServerUtility rsql = new RelationSqlServerUtility();

            if (!string.IsNullOrEmpty(old))
            {
                string strsql = "select distinct new from RField where old='{0}'";

                DataSet ds = rsql.ExecuteSqlDataSet(string.Format(strsql, old));

                if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0 && ds.Tables[0].Columns.Count > 0)
                {
                    result = new Guid(ds.Tables[0].Rows[0][0].ToString());
                }
            }
            return result;
        }
Пример #8
0
        /// <summary>
        /// OK
        /// </summary>
        /// <param name="old"></param>
        /// <returns></returns>
        public static Guid TransferTradeId(string old)
        {
            try
            {
                if (!string.IsNullOrEmpty(old))
                {
                    RelationSqlServerUtility rsql = new RelationSqlServerUtility();

                    string strsql = "Select distinct new from RTrade where old='{0}'";

                    DataSet ds = rsql.ExecuteSqlDataSet(string.Format(strsql, old));

                    if (ds != null && ds.Tables[0].Rows.Count > 0 && ds.Tables[0].Rows.Count > 0 && ds.Tables[0].Columns.Count > 0)
                    {
                        return new Guid(ds.Tables[0].Rows[0][0].ToString());
                    }
                    else
                    {
                        return Guid.Empty;
                    }
                }
                return Guid.Empty;

            }
            catch (Exception ex)
            {
                throw ex;
            }
        }