예제 #1
0
        public void bindData(int page=0, int size=20, string q="")
        {
            this.labelLoading.Text = "正在加载。。。";
            try
            {
                Response res = new Response();
                System.Collections.Generic.List<Artifact.Api.User> users = res.UserList(0,page,size,q);
                if (users != null)
                {
                    Extra extra = (Extra)JsonConvert.DeserializeObject(res.extra.ToString(), typeof(Extra));
                    this.pageCount = extra.pages;
                    this.pageCurrent = extra.page;
                    this.pageSize = extra.size;
                    this.totalRecord = extra.total;

                    this.userBindingSource.DataSource = users;
                }

                this.textBoxPage.Text = (this.pageCurrent + 1).ToString();
                this.labelTotalPage.Text = "/" + this.pageCount.ToString();

                //有下一页
                if (this.pageCurrent > 0)
                {
                    this.buttonFirst.Enabled = true;
                    this.buttonPre.Enabled = true;
                }
                else
                {
                    this.buttonFirst.Enabled = false;
                    this.buttonPre.Enabled = false;
                }
                if (this.pageCount > (this.pageCurrent+1))
                {
                    this.buttonNext.Enabled = true;
                    this.buttonLast.Enabled = true;
                }
                else //无下一页
                {
                    this.buttonNext.Enabled = false;
                    this.buttonLast.Enabled = false;
                }

            }
            catch (Exception )
            {
                //MessageBox.Show("获取信息出错!" + ex.Message);
            }

            this.labelLoading.Text = "";
        }
예제 #2
0
        private void buttonOk_Click(object sender, EventArgs e)
        {
            if (this.textBoxCode.Text == "")
            {
                MessageBox.Show("请填写账号。", "提示信息");
                this.textBoxCode.Focus();
                return;
            }
            if (this.textBoxPassword.Text == "")
            {
                MessageBox.Show("请填写密码。", "提示信息");
                this.textBoxPassword.Focus();
                return;
            }
            try
            {
                Response res = new Response();
                Artifact.Api.User user = new Api.User();
                user.user_code = this.textBoxCode.Text;
                user.user_name = this.textBoxName.Text;
                user.user_password = this.textBoxPassword.Text;
                user.user_remark = this.richTextBoxRemark.Text;
                user.role_id = this.comboBoxRole.SelectedIndex.ToString();
                user.user_expire = this.dateTimePickerExpire.Text;
                user.user_email = "";
                user.user_mobile = "";

                if (this.radioButtonService.Checked == true)
                    user.user_is_service = "1";

                Artifact.Api.User user_add = res.UserCreate(user);
                if (user_add != null)
                {
                    MessageBox.Show("添加成功!");
                    this.textBoxCode.Text = "";
                }
                else
                    MessageBox.Show("添加失败!" + res.message);

            }
            catch (Exception ex)
            {
                MessageBox.Show("获取信息出错!" + ex.Message);
            }
        }
예제 #3
0
        private void buttonOk_Click(object sender, EventArgs e)
        {
            if (this.textBoxOldPassword.Text == "")
            {
                MessageBox.Show("请填写旧密码。", "提示信息");
                this.textBoxOldPassword.Focus();
                return;
            }
            if (this.textBoxNewPassword.Text == "")
            {
                MessageBox.Show("请填写新密码。", "提示信息");
                this.textBoxNewPassword.Focus();
                return;
            }

            try
            {
                Response res = new Response();
                User user = Program.user;
                if (user != null)
                {
                    if (res.UserReset(this.textBoxOldPassword.Text,this.textBoxNewPassword.Text))
                    {
                        MessageBox.Show("修改成功!");
                    }
                    else
                        MessageBox.Show("修改失败!"+res.message);

                }
                else
                {
                    MessageBox.Show("登录过期!");
                }

            }
            catch (Exception ex)
            {
                MessageBox.Show("获取信息出错!" + ex.Message);
            }
        }
예제 #4
0
        private void buttonSubmit_Click(object sender, EventArgs e)
        {
            if (this.textBoxCode.Text == "")
            {
                MessageBox.Show("请填写账号。", "提示信息");
                this.textBoxCode.Focus();
                return;
            }
            if (this.textBoxPassword.Text == "")
            {
                MessageBox.Show("请填写密码。", "提示信息");
                this.textBoxPassword.Focus();
                return;
            }

            Response res = new Response();
            try
            {
                User user = res.UserLogin(this.textBoxCode.Text, this.textBoxPassword.Text);
                if (user != null)
                {

                    this.DialogResult = DialogResult.OK;

                }
                else
                {
                    MessageBox.Show("登录失败!" + res.message, "操作提示");
                }
            }
            catch (Exception )
            {
                MessageBox.Show("登录失败!","操作提示");
                //Console.WriteLine(" form login 出错 " + ex.Message);
            }
        }
예제 #5
0
 private void toolStripMenuItemDelete_Click(object sender, EventArgs e)
 {
     try
     {
         if (this.dataGridViewMessageList.DataSource == null || this.dataGridViewMessageList.CurrentRow == null)
         {
             return;
         }
         else
         {
             if (this.dataGridViewMessageList.SelectedRows.Count > 0)
             {
                 DialogResult dr = MessageBox.Show("确定删除选中的记录? ", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
                 if (dr == DialogResult.OK)
                 {
                     try
                     {
                         Response res = new Response();
                         //遍历所选中的dataGridView记录行
                         foreach (DataGridViewRow row in this.dataGridViewMessageList.SelectedRows)
                         {
                             //取dataGridView1中的第三列的值
                             string id = row.Cells[0].Value.ToString();
                             this.dataGridViewMessageList.Rows.Remove(row);
                             res.MessageDelete(id);
                         }
                     }
                     catch (Exception ex)
                     {
                         MessageBox.Show(ex.ToString(), "提示");
                     }
                     //删除后执行刷新操作
                 }
             }
         }
     }
     catch (Exception )
     {
     }
 }
예제 #6
0
        public void refreshChat()
        {
            try
            {
                User user = selectUser();
                Response res = new Response();
                System.Collections.Generic.List<Artifact.Api.Chat> chats = res.ChatList(this.maxId,user.user_id, 0, 20);
                if (chats != null)
                {
                    User currentUser = Program.user;
                    this.richTextBoxHistory.Select(this.richTextBoxHistory.TextLength, 0);
                    foreach (Artifact.Api.Chat chat in chats)
                    {
                        if (chat.user_id == currentUser.user_id)
                        {
                            this.richTextBoxHistory.SelectionAlignment = HorizontalAlignment.Right;
                        }
                        else
                        {
                            this.richTextBoxHistory.SelectionAlignment = HorizontalAlignment.Left;
                        }
                        this.richTextBoxHistory.AppendText(chat.user + " " + chat.chat_created + "\n" + chat.chat_text + "\n\n");
                        //this.richTextBoxHistory.AppendText(chat.to_user + " " + chat.chat_created + "\n" + chat.chat_text + "\n\n");
                        if (this.maxId < Int32.Parse(chat.chat_id))
                            this.maxId = Int32.Parse(chat.chat_id);

                    }

                    Regex regImg = new Regex(@"(?i)<img\b[^>]*?src\s*=(['""]?)(?<imgUrl>[^'""]+)\1[^>]*?>");
                    MatchCollection matches = regImg.Matches(this.richTextBoxHistory.Text);

                    string[] sUrlList = new string[matches.Count];
                    foreach (Match match in matches)
                    {

                        string url = @match.Groups["imgUrl"].Value;
                        Bitmap bmp = new Bitmap((new System.Net.WebClient()).OpenRead(url));
                        Clipboard.SetImage(bmp);
                        string src = "<img src='" + url + "' />";
                        int pos = this.richTextBoxHistory.Find(src);
                        this.richTextBoxHistory.Select(pos, src.Length);
                        this.richTextBoxHistory.Paste();
                        this.richTextBoxHistory.Refresh();
                        Clipboard.Clear();
                    }

                    //让文本框获取焦点
                    this.richTextBoxHistory.Focus();
                    //设置光标的位置到文本尾
                    this.richTextBoxHistory.Select(this.richTextBoxHistory.TextLength, 0);
                    //滚动到控件光标处
                    this.richTextBoxHistory.ScrollToCaret();
                    if (this.WindowState == FormWindowState.Minimized)
                        this.WindowState = FormWindowState.Normal;

                    String wav = @"msg.wav";
                    if (System.IO.File.Exists(wav))
                    {
                        System.Media.SoundPlayer sp = new System.Media.SoundPlayer(wav);
                        sp.Play();
                    }
                }

            }
            catch (Exception)
            {
                //MessageBox.Show("获取信息出错!" + ex.Message);
            }
        }
예제 #7
0
 private void ChatForm_Load(object sender, EventArgs e)
 {
     try
     {
         Response res = new Response();
         System.Collections.Generic.List<Artifact.Api.User> users =null;
         if(Program.user.user_is_service == "1")
             users = res.ChatUser();
         else
             users = res.UserService();
         if (users != null)
         {
             this.bindingSourceService.DataSource = users;
             this.listBoxService.DisplayMember = "user_name";
             this.listBoxService.ValueMember = "user_id";
             User user = selectUser();
             this.labelCurrent.Text = user.user_name;
         }
         refreshChat();
     }
     catch (Exception)
     {
         //MessageBox.Show("获取信息出错!" + ex.Message);
     }
 }
예제 #8
0
        private void buttonSend_Click(object sender, EventArgs e)
        {
            if (this.richTextBoxChat.Text == "")
            {
                MessageBox.Show("请填写信息。", "提示信息");
                this.richTextBoxChat.Focus();
                return;
            }

            try
            {
                //label1.Text = "正在发布中。。。。";
                Response res = new Response();

                Artifact.Api.Chat chat = new Api.Chat();
                string filePath = Application.StartupPath + "\\chat\\" + DateTime.Now.ToString("yyyyMMdd") + "\\";//存放到相对路径

                Random seed = new Random();

                if (!Directory.Exists(filePath))
                {
                    Directory.CreateDirectory(filePath);
                }
                string text = "";
                for (int i = 0; i < this.richTextBoxChat.TextLength; i++)
                {
                    this.richTextBoxChat.Select(i, 1);
                    RichTextBoxSelectionTypes rt = this.richTextBoxChat.SelectionType;
                    //MessageBox.Show(rt.ToString());
                    if (rt == RichTextBoxSelectionTypes.Object)
                    {
                        //label1.Text = "正在上传截图。。。。";
                        //当然也可能是其它的类型
                        //MessageBox.Show("这是一个图片");
                        this.richTextBoxChat.Copy();
                        Image img = Clipboard.GetImage();
                        if (img != null)
                        {
                            //string snapPath = filePath + DateTime.Now.ToString("HHmmss") + seed.Next(10, 99).ToString() + ".jpg";
                            //img.Save(snapPath, ImageFormat.Jpeg);

                            //上传到服务器
                            Snap snap = res.ChatUpload(img);
                            img.Dispose();

                            if (snap != null)
                            {
                                text += "<img src='" + snap.url + "' />";
                            }
                        }
                        //label1.Text = "上传完成";
                    }
                    else
                        text += this.richTextBoxChat.SelectedText;

                }

                chat.chat_text = text;
                if (this.listBoxService.Items.Count > 0)
                {
                    User user = (User)this.listBoxService.SelectedItem;
                    chat.chat_user_id = user.user_id;
                }
                Artifact.Api.Chat chat_add = res.ChatCreate(chat);
                if (chat_add != null)
                {
                    this.richTextBoxChat.Text = "";
                    //MessageBox.Show("发布成功!", "提示信息");
                }
                else
                    MessageBox.Show("发布失败!" + res.message, "提示信息");

                //label1.Text = "";

            }
            catch (Exception ex)
            {
                MessageBox.Show("获取信息出错!" + ex.Message);
            }
        }
예제 #9
0
        private void dataGridViewUserList_CellValueChanged(object sender, DataGridViewCellEventArgs e)
        {
            try
            {
                if (this.dataGridViewUserList.DataSource == null || this.dataGridViewUserList.CurrentRow == null)
                {
                    return;
                }
                else
                {
                    if (this.dataGridViewUserList.SelectedRows.Count > 0)
                    {
                        DialogResult dr = MessageBox.Show("数据有更改,是否保存? ", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
                        if (dr == DialogResult.OK)
                        {
                            try
                            {
                                Response res = new Response();
                                DataGridViewRow row = this.dataGridViewUserList.CurrentRow;
                                User user = new User();
                                user.user_id = row.Cells[0].Value.ToString();
                                user.role_id = row.Cells[1].Value.ToString();
                                user.user_code = row.Cells[2].Value.ToString();
                                user.user_password = row.Cells[3].Value.ToString();
                                user.user_expire = row.Cells[4].Value.ToString();
                                user.user_name = row.Cells[5].Value.ToString();
                                user.user_mobile = row.Cells[6].Value.ToString();
                                user.user_email = row.Cells[7].Value.ToString();
                                user.user_remark = row.Cells[8].Value.ToString();
                                user.user_is_service = row.Cells[9].Value.ToString();

                                if (res.UserUpdate(user) != null)
                                    MessageBox.Show("保存成功", "提示");

                            }
                            catch (Exception ex)
                            {
                                MessageBox.Show(ex.ToString(), "提示");
                            }
                            //删除后执行刷新操作
                        }
                    }
                }
            }
            catch (Exception )
            {
            }
        }
예제 #10
0
        private void buttonAdd_Click(object sender, EventArgs e)
        {
            if (this.richTextBoxText.Text == "")
            {
                MessageBox.Show("请填写信息。", "提示信息");
                this.richTextBoxText.Focus();
                return;
            }

            try
            {
                label1.Text = "正在发布中。。。。";
                Response res = new Response();
                int exp = this.checkBoxExp.Checked ? 1 : 0;
                Artifact.Api.Message message = new Api.Message();
                message.message_is_exp = exp.ToString();
                string filePath = Application.StartupPath + "\\snap\\" + DateTime.Now.ToString("yyyyMMdd") + "\\";//存放到相对路径

                Random seed = new Random();

                if (!Directory.Exists(filePath))
                {
                    Directory.CreateDirectory(filePath);
                }
                string text = "";
                for (int i = 0; i < this.richTextBoxText.TextLength; i++)
                {
                    this.richTextBoxText.Select(i, 1);
                    RichTextBoxSelectionTypes rt = this.richTextBoxText.SelectionType;
                    //MessageBox.Show(rt.ToString());
                    if (rt == RichTextBoxSelectionTypes.Object)
                    {
                        label1.Text = "正在上传截图。。。。";
                        //当然也可能是其它的类型
                        //MessageBox.Show("这是一个图片");
                        this.richTextBoxText.Copy();
                        Image img = Clipboard.GetImage();
                        if (img != null)
                        {
                            //string snapPath = filePath + DateTime.Now.ToString("HHmmss") + seed.Next(10, 99).ToString() + ".jpg";
                            //img.Save(snapPath, ImageFormat.Jpeg);

                            //上传到服务器
                            Snap snap = res.MessageUpload(img);
                            img.Dispose();

                            if (snap != null)
                            {
                                text += "<img src='"+snap.url+"' />" ;
                            }
                        }
                        label1.Text = "上传完成";
                    }
                    else
                        text += this.richTextBoxText.SelectedText;

                }

                message.message_text = text;

                Artifact.Api.Message message_add = res.MessageCreate(message);
                if (message_add != null)
                {
                    this.richTextBoxText.Text = "";
                    MessageBox.Show("发布成功!","提示信息");
                }
                else
                    MessageBox.Show("发布失败!" + res.message, "提示信息");

                label1.Text = "";

            }
            catch (Exception ex)
            {
                MessageBox.Show("获取信息出错!" + ex.Message);
            }
        }