Esempio n. 1
0
        private void 确定ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Stream fs  = null;
            int    st  = 0;
            int    end = 0;

            try
            {
                st  = int.Parse(toolStripTextBoxGBStart.Text);
                end = int.Parse(toolStripTextBoxGBEnd.Text);
                saveFileDialogText();
                if (saveFileDialog.ShowDialog(this) == DialogResult.OK)
                {
                    fs = File.Create(saveFileDialog.FileName);
                    GB2312.GetChars(fs, st, end);
                }
            }
            catch (Exception ee)
            {
                MessageBox.Show(this, ee.Message, "出错了");
                return;
            }
            finally
            {
                if (fs != null)
                {
                    fs.Dispose();
                }
            }
        }
Esempio n. 2
0
 private void gB2312ToolStripMenuItem_Click(object sender, EventArgs e)
 {
     saveFileDialogText();
     if (saveFileDialog.ShowDialog(this) == DialogResult.OK)
     {
         Stream fs = File.Create(saveFileDialog.FileName);
         if (sender == this.toolStripMenuItemGB2312All)
         {
             GB2312.GetAllChars(fs);
         }
         else if (sender == this.一级简码ToolStripMenuItem)
         {
             GB2312.GetStairChars(fs);
         }
         else if (sender == this.二级简码ToolStripMenuItem)
         {
             GB2312.GetSecondaryChars(fs);
         }
         else if (sender == this.ASCII全部ToolStripMenuItem)
         {
             ASCII.GetAllChars(fs);
         }
         fs.Dispose();
     }
 }
Esempio n. 3
0
        void Item2Buffer(ByteBuilder Buf, CSaleItem item)
        {
            int    index = productBindingSource.Find("ProductID", item.ProductID);
            string s     = "產品" + item.ProductID.ToString();

            if (index >= 0)
            {
                object       o  = productBindingSource.DataSource;
                BasicDataSet ds = (BasicDataSet)o;
                BasicDataSet.ProductDataTable t   = ds.Product;
                BasicDataSet.ProductRow       row = t[index];
                s = row.Name;
            }

            int m;

            do
            {
                m = GB2312.GetByteCount(s);
                if (m <= 16)
                {
                    break;
                }
                s = s.Substring(0, s.Length - 1);
            } while (true);
            int n = 16 - m + s.Length;

            Buf.AppendPadRight(s, n, GB2312);
            Buf.Append(d2str(item.Volume, 6), GB2312);
//            Buf.Append(d2str(item.Price  , 5), GB2312);
            Buf.Append(d2str(item.Total, 10), GB2312);
            Buf.Append("\r\n", GB2312);
        }
Esempio n. 4
0
        private void toolStripButton1_Click(object sender, EventArgs e)
        {
            SaveFileDialog sf = new SaveFileDialog();

            if (sf.ShowDialog(this) == DialogResult.OK)
            {
                Stream fs = File.Create(sf.FileName);
                GB2312.GetAllChars(fs);
                fs.Dispose();
            }
        }
Esempio n. 5
0
        /// <summary> 
        /// 得到一个汉字的拼音第一个字母,如果是一个英文字母则直接返回
        /// </summary> 
        /// <param name="character">汉字字符</param>
        /// <param name="upper">若返回大写则为真,小写则为假</param>
        /// <returns>单个大写字母</returns> 
        public static char GetSpellCode(char character, bool upper = true)
        {
            string cstr = character.ToString();
            byte[] cnbytes = GB2312.GetBytes(cstr);
            if (cnbytes.Length == 1) // 如果是英文字母,则直接返回
            {
                if (upper) return cstr.ToUpper()[0];
                else return cstr.ToLower()[0];
            }
            
            switch(character) // 二级汉字无法通过位置来判断拼音,这里直接列出来
            {
                case '邳': return upper ? 'P' : 'p';
                case '睿': return upper ? 'R' : 'r';
                case '悚':
                case '泗':
                    return upper ? 'S' : 's';
                case '学':
                case '讯':
                    return upper ? 'X' : 'x';
                case '圳': return upper ? 'Z' : 'z';
                default:
                    int ichar = cnbytes[0] << 8 | cnbytes[1];
                    if ((ichar >= 45217) && (ichar <= 45252)) return upper ? 'A' : 'a';
                    else if ((ichar >= 45253) && (ichar <= 45760)) return upper ? 'B' : 'b';
                    else if ((ichar >= 45761) && (ichar <= 46317)) return upper ? 'C' : 'c';
                    else if ((ichar >= 46318) && (ichar <= 46825)) return upper ? 'D' : 'd';
                    else if ((ichar >= 46826) && (ichar <= 47009)) return upper ? 'E' : 'e';
                    else if ((ichar >= 47010) && (ichar <= 47296)) return upper ? 'F' : 'f';
                    else if ((ichar >= 47297) && (ichar <= 47613)) return upper ? 'G' : 'g';
                    else if ((ichar >= 47614) && (ichar <= 48118)) return upper ? 'H' : 'h';
                    else if ((ichar >= 48119) && (ichar <= 49061)) return upper ? 'J' : 'j';
                    else if ((ichar >= 49062) && (ichar <= 49323)) return upper ? 'K' : 'k';
                    else if ((ichar >= 49324) && (ichar <= 49895)) return upper ? 'L' : 'l';
                    else if ((ichar >= 49896) && (ichar <= 50370)) return upper ? 'M' : 'm';
                    else if ((ichar >= 50371) && (ichar <= 50613)) return upper ? 'N' : 'n';
                    else if ((ichar >= 50614) && (ichar <= 50621)) return upper ? 'O' : 'o';
                    else if ((ichar >= 50622) && (ichar <= 50905)) return upper ? 'P' : 'p';
                    else if ((ichar >= 50906) && (ichar <= 51386)) return upper ? 'Q' : 'q';
                    else if ((ichar >= 51387) && (ichar <= 51445)) return upper ? 'R' : 'r';
                    else if ((ichar >= 51446) && (ichar <= 52217)) return upper ? 'S' : 's';
                    else if ((ichar >= 52218) && (ichar <= 52697)) return upper ? 'T' : 't';
                    else if ((ichar >= 52698) && (ichar <= 52979)) return upper ? 'W' : 'w';
                    else if ((ichar >= 52980) && (ichar <= 53640)) return upper ? 'X' : 'x';
                    else if ((ichar >= 53689) && (ichar <= 54480)) return upper ? 'Y' : 'y';
                    else if ((ichar >= 54481) && (ichar <= 55289)) return upper ? 'Z' : 'z';
                    else return ('?');
            }

        }
Esempio n. 6
0
        /// <summary>
        /// 获得文件列表
        /// </summary>
        /// <param name="strMask">文件名的匹配字符串</param>
        /// <returns></returns>
        public string[] Dir(string strMask)
        {
            // 建立链接
            if (!bConnected)
            {
                Connect();
            }

            //建立进行数据连接的socket
            Socket socketData = CreateDataSocket();

            //传送命令
            SendCommand("LIST " + strMask);

            //分析应答代码
            if (!(iReplyCode == 150 || iReplyCode == 125 || iReplyCode == 226))
            {
                throw new IOException(strReply.Substring(4));
            }

            //获得结果
            strMsg = "";
            while (true)
            {
                int iBytes = socketData.Receive(buffer, buffer.Length, 0);
                strMsg += GB2312.GetString(buffer, 0, iBytes);
                if (iBytes < buffer.Length)
                {
                    break;
                }
            }
            char[]   seperator    = { '\n' };
            string[] strsFileList = strMsg.Split(seperator);
            socketData.Close();//数据socket关闭时也会有返回码
            if (iReplyCode != 226)
            {
                ReadReply();
                if (iReplyCode != 226)
                {
                    throw new IOException(strReply.Substring(4));
                }
            }
            return(strsFileList);
        }
Esempio n. 7
0
        void Item2Buffer(ByteBuilder Buf, CSaleItem item)
        {
            string s = "產品" + item.ProductID.ToString();
            //int index = productBindingSource.Find("ProductID", item.ProductID);
            //
            //if (index >= 0)
            //{
            //    object o = productBindingSource.DataSource;
            //    BasicDataSet ds=(BasicDataSet)o;
            //    BasicDataSet.ProductDataTable t = ds.Product;
            //    BasicDataSet.ProductRow row = t[index];
            //    s = row.Name;
            //}
            var pr = from r in m_OrderSet.Product where r.ProductID == item.ProductID select r;

            if (pr.Count() > 0)
            {
                if (!pr.First().IsNameNull())
                {
                    s = pr.First().Name;
                }
            }
            int m;

            do
            {
                m = GB2312.GetByteCount(s);
                if (m <= 16)
                {
                    break;
                }
                s = s.Substring(0, s.Length - 1);
            } while (true);
            int n = 16 - m + s.Length;

            Buf.AppendPadRight(s, n, GB2312);
            Buf.Append(d2str(item.Volume, 6), GB2312);
//            Buf.Append(d2str(item.Price  , 5), GB2312);
            Buf.Append(d2str(item.Total, 10), GB2312);
            Buf.Append("\r\n", GB2312);
        }