コード例 #1
0
        public bool Insert_OutFallExtInfo(ref COutFallExtInfo outfall)
        {
            MySqlDataReader reader;
            string          strcmd = "INSERT INTO [OutFallExtInfo]([OutFallID],[OutFallName],[OutFallAddr],[Flap_Material],[Flap_Diameter]," +
                                     "[Flap_TopEle],[Flap_BotEle],[TopEle],[NormalLevel],[Tidal_Curve],[Status],[Remark]) values(" + outfall.OutFallID + ",'" +
                                     outfall.OutFallName + "','" + outfall.OutFallAddr + "', " + outfall.Flap_Material + " ,'" + outfall.Flap_Diameter + "','" + outfall.Flap_TopEle
                                     + "','" + outfall.Flap_BotEle + "','" + outfall.TopEle + "','" + outfall.NormalLevel + "','" + outfall.Tidal_Curve + "'," + outfall.Status +
                                     " ,'" + outfall.Remark + "')";

            try
            {
                connect.Open();
                MySqlCommand cmd = new MySqlCommand();
                cmd.Connection  = connect;
                cmd.CommandType = CommandType.Text;
                cmd.CommandText = strcmd;

                strcmd = "SELECT MAX([ID]) AS MAXID FROM [OutFallExtInfo]";
                cmd.ExecuteNonQuery();
                cmd.CommandText = strcmd;
                reader          = cmd.ExecuteReader();
                reader.Read();
                outfall.ID = Convert.ToInt32(reader[0].ToString());
            }
            catch (System.Exception ex)
            {
                Console.WriteLine(ex.Message);
                return(false);
            }
            finally
            {
                connect.Close();
            }
            return(true);
        }
コード例 #2
0
        public bool Delete_OutFallExtInfo(COutFallExtInfo outfall)
        {
            List <string> listcmd = new List <string>();

            try
            {
                string cmd = "DELETE * FROM [OutFallExtInfo] where ID = " + outfall.ID;
                listcmd.Add(cmd);
                ExectueCmd(listcmd);
            }
            catch (System.Exception ex)
            {
                Console.WriteLine(ex.Message);
                return(false);
            }
            return(true);
        }
コード例 #3
0
ファイル: OutFallRev.cs プロジェクト: chijianfeng/PNManager
        /// <summary>
        /// 插入出水口信息,同时添加出水口附加信息,若不存在则创建新信息
        /// </summary>
        /// <returns></returns>
        private bool DoInsert()
        {
            TOutFallInfo    outinfo    = new TOutFallInfo(_dbpath, PassWord);
            TOutFallExtInfo outextinfo = new TOutFallExtInfo(_dbpath, PassWord);

            if (OutList == null || OutList.Count <= 0)
            {
                return(false);
            }
            int count = 0;

            foreach (COutFallInfo info in OutList)
            {
                COutFallInfo tmp = info;
                if (!outinfo.Insert_OutFallInfo(ref tmp))
                {
                    continue;
                }
                COutFallExtInfo extmp = null;
                if (OutExtList == null)
                {
                    extmp = new COutFallExtInfo();
                }
                else
                {
                    if (count < OutExtList.Count)
                    {
                        extmp = OutExtList.ElementAt(count);
                    }
                    else
                    {
                        extmp = new COutFallExtInfo();
                    }
                }
                extmp.OutFallID = tmp.ID;
                outextinfo.Insert_OutFallExtInfo(ref extmp);
                count++;
            }
            if (count <= 0)
            {
                return(false);
            }
            return(true);
        }
コード例 #4
0
        private List <COutFallExtInfo> Select(string cmd)
        {
            List <COutFallExtInfo> listout = new List <COutFallExtInfo>();
            MySqlCommand           com;
            MySqlDataReader        reader;

            try
            {
                connect.Open();
                com    = new MySqlCommand(cmd, connect);
                reader = com.ExecuteReader();
                while (reader.Read())
                {
                    COutFallExtInfo outfall = new COutFallExtInfo();
                    int             i       = 0;
                    string          tmp;
                    outfall.ID = Convert.ToInt32(reader[i++].ToString());
                    tmp        = reader[i++].ToString();
                    if (tmp != null && tmp.Length > 0)
                    {
                        outfall.OutFallID = Convert.ToInt32(tmp);
                    }
                    outfall.OutFallName = reader[i++].ToString();
                    outfall.OutFallAddr = reader[i++].ToString();
                    tmp = reader[i++].ToString();
                    if (tmp != null && tmp.Length > 0)
                    {
                        outfall.Flap_Material = Convert.ToInt32(tmp);
                    }
                    tmp = reader[i++].ToString();
                    if (tmp != null && tmp.Length > 0)
                    {
                        outfall.Flap_Diameter = Convert.ToDouble(tmp);
                    }
                    tmp = reader[i++].ToString();
                    if (tmp != null && tmp.Length > 0)
                    {
                        outfall.Flap_TopEle = Convert.ToDouble(tmp);
                    }
                    tmp = reader[i++].ToString();
                    if (tmp != null && tmp.Length > 0)
                    {
                        outfall.Flap_BotEle = Convert.ToDouble(tmp);
                    }
                    tmp = reader[i++].ToString();
                    if (tmp != null && tmp.Length > 0)
                    {
                        outfall.TopEle = Convert.ToDouble(tmp);
                    }
                    tmp = reader[i++].ToString();
                    if (tmp != null && tmp.Length > 0)
                    {
                        outfall.NormalLevel = Convert.ToDouble(tmp);
                    }
                    tmp = reader[i++].ToString();
                    if (tmp != null && tmp.Length > 0)
                    {
                        outfall.Tidal_Curve = Convert.ToDouble(tmp);
                    }
                    tmp = reader[i++].ToString();
                    if (tmp != null && tmp.Length > 0)
                    {
                        outfall.Status = Convert.ToInt32(tmp);
                    }
                    outfall.Remark = reader[i++].ToString();
                    listout.Add(outfall);
                }
            }
            catch (System.Exception ex)
            {
                Console.WriteLine(ex.Message);
                return(null);
            }
            finally
            {
                connect.Close();
            }
            return(listout);
        }