Пример #1
0
        public void RefreshChat_Append()
        {
            try
            {
                if (dt.Rows.Count > 0)
                {
                    LastID = DBase.IntReturn(dt.Rows[dt.Rows.Count - 1]["ID"]);
                }
                else
                {
                    LastID = 0;
                }
                if (dtnew.Rows.Count > 0)
                {
                    LastID = DBase.IntReturn(dtnew.Rows[dtnew.Rows.Count - 1]["ID"]);
                }
                dtnew = DHuy.SELECT_SQL("SELECT * FROM CHAT WHERE ID > @DATE1 AND USERCODE = '" + Control_Remote + "' ORDER BY ID ASC ", LastID.ToString());
                for (int i = 0; i < dtnew.Rows.Count; i++)
                {
                    String type = DBase.StringReturn(dtnew.Rows[i]["TYPE"]);
                    if (type == "")
                    {
                        ChatItem C = new ChatItem();
                        C.Width = panChat.Width;
                        C.M     = this;
                        C.ID    = DBase.IntReturn(dtnew.Rows[i]["ID"]);
                        String DataNick = DBase.StringReturn(dtnew.Rows[i]["NICKNAME"]) + " ";

                        String   Text      = DBase.StringReturn(dtnew.Rows[i]["TEXT"]);
                        DateTime cdatetime = DBase.DatetimeReturn(dtnew.Rows[i]["CDATETIME"]);

                        if (curNick == DataNick)
                        {
                            //C.edtUserCode.ForeColor = C.edtUserCode.BackColor;
                            //C.edtIcon.Visible = false;
                            ////  else C.edtUserCode.ForeColor = Color.Blue;

                            colorIndex++;
                            //  C.edtIcon.Visible = true;
                            if (colorIndex == C.L.Count)
                            {
                                colorIndex = 0;
                            }
                            // C.edtUserCode.ForeColor = Color.Blue;
                        }
                        else
                        {
                            colorIndex++;
                            //  C.edtIcon.Visible = true;
                            if (colorIndex == C.L.Count)
                            {
                                colorIndex = 0;
                            }
                            //  C.edtUserCode.ForeColor = Color.Blue;
                        }

                        curNick = DataNick;

                        C.BackColor = C.edtText.BackColor = C.L[colorIndex];

                        //   C.edtUserCode.Text = DataNick + ":";
                        C.edtText.Text = DataNick + ": " + Text + "  ( " + cdatetime.ToString("dd/MM HH:mm") + " )";

                        panChat.Controls.Add(C);
                    }

                    else if (type.ToUpper() == ".JPG" || type.ToUpper() == ".BMP" || type.ToUpper() == ".PNG" || type.ToUpper() == ".GIF")
                    {
                        try
                        {
                            String         FileName = DBase.StringReturn(dtnew.Rows[i]["FILENAME"]);
                            Image          I        = DBase.ByteToImage((byte[])dtnew.Rows[i]["THUMBNAIL"]);
                            ChatItem_Image C        = new ChatItem_Image(I, FileName);

                            C.M  = this;
                            C.ID = DBase.IntReturn(dt.Rows[i]["ID"]);
                            DateTime cdatetime = DBase.DatetimeReturn(dtnew.Rows[i]["CDATETIME"]);

                            panChat.Controls.Add(C);
                        }
                        catch (Exception ex) { }
                    }

                    else if (type != "")
                    {
                        try
                        {
                            String FileName = DBase.StringReturn(dtnew.Rows[i]["FILENAME"]);
                            Image  I        = null;
                            try
                            {
                                I = DBase.ByteToImage((byte[])dtnew.Rows[i]["THUMBNAIL"]);
                            }
                            catch (Exception ex) { }
                            ChatItem_Files C = new ChatItem_Files(type, FileName, I);

                            C.M  = this;
                            C.ID = DBase.IntReturn(dtnew.Rows[i]["ID"]);
                            DateTime cdatetime = DBase.DatetimeReturn(dtnew.Rows[i]["CDATETIME"]);

                            panChat.Controls.Add(C);
                        }
                        catch (Exception ex) { }
                    }
                }

                if (dtnew.Rows.Count > 0)
                {
                    dt.Merge(dtnew);
                    panChat.VerticalScroll.Value = panChat.VerticalScroll.Maximum;
                }
            }
            catch (Exception ex) { }
        }
Пример #2
0
        public void RefreshChat()
        {
            dtnew  = new DataTable();
            LastID = 0;
            try
            {
                string lastUser = "";
                panChat.Controls.Clear();
                //ChatItem None = new ChatItem();
                //None.BackColor = None.edtText.BackColor = Color.Snow;
                //panChat.Controls.Add(None);
                dt = DHuy.SELECT_SQL("SELECT * FROM CHAT WHERE USERCODE = '" + Control_Remote + "' ORDER BY ID ASC ");

                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    String type = DBase.StringReturn(dt.Rows[i]["TYPE"]);

                    if (type == "")
                    {
                        ChatItem C = new ChatItem();
                        C.Width = panChat.Width;
                        C.M     = this;
                        C.ID    = DBase.IntReturn(dt.Rows[i]["ID"]);
                        String   DataNick    = DBase.StringReturn(dt.Rows[i]["NICKNAME"]) + " ";
                        String   ColorString = "";
                        String   Text        = DBase.StringReturn(dt.Rows[i]["TEXT"]);
                        DateTime cdatetime   = DBase.DatetimeReturn(dt.Rows[i]["CDATETIME"]);

                        if (curNick == DataNick)
                        {
                            //  C.edtUserCode.ForeColor = C.edtUserCode.BackColor;
                            //  C.edtIcon.Visible = false;
                            ////  else C.edtUserCode.ForeColor = Color.Blue;
                            colorIndex++;
                            //  C.edtIcon.Visible = true;
                            if (colorIndex == C.L.Count)
                            {
                                colorIndex = 0;
                            }
                            //   C.edtUserCode.ForeColor = Color.Blue;
                        }
                        else
                        {
                            colorIndex++;
                            //  C.edtIcon.Visible = true;
                            if (colorIndex == C.L.Count)
                            {
                                colorIndex = 0;
                            }
                            //   C.edtUserCode.ForeColor = Color.Blue;
                        }

                        curNick = DataNick;

                        C.BackColor = C.edtText.BackColor = C.L[colorIndex];

                        //   C.edtUserCode.Text = DataNick + ":";
                        C.edtText.Text = DataNick + ": " + Text + "  ( " + cdatetime.ToString("dd/MM HH:mm") + " )";
                        if (ColorString == "RED")
                        {
                            // C.BackColor = Color.Pink;
                            C.edtText.BackColor = Color.Pink;
                        }
                        else if (ColorString == "GREEN")
                        {
                            C.BackColor         = Color.Honeydew;
                            C.edtText.BackColor = Color.Honeydew;
                        }

                        panChat.Controls.Add(C);
                    }

                    else if (type.ToUpper() == ".JPG" || type.ToUpper() == ".BMP" || type.ToUpper() == ".PNG" || type.ToUpper() == ".GIF")
                    {
                        try
                        {
                            String         FileName = DBase.StringReturn(dt.Rows[i]["FILENAME"]);
                            Image          I        = DBase.ByteToImage((byte[])dt.Rows[i]["THUMBNAIL"]);
                            ChatItem_Image C        = new ChatItem_Image(I, FileName);

                            C.M  = this;
                            C.ID = DBase.IntReturn(dt.Rows[i]["ID"]);
                            DateTime cdatetime = DBase.DatetimeReturn(dt.Rows[i]["CDATETIME"]);

                            panChat.Controls.Add(C);
                        }
                        catch (Exception ex) { }
                    }

                    else if (type != "")
                    {
                        try
                        {
                            String FileName = DBase.StringReturn(dt.Rows[i]["FILENAME"]);
                            Image  I        = null;
                            try
                            {
                                I = DBase.ByteToImage((byte[])dt.Rows[i]["THUMBNAIL"]);
                            }
                            catch (Exception ex) { }
                            ChatItem_Files C = new ChatItem_Files(type, FileName, I);

                            C.M  = this;
                            C.ID = DBase.IntReturn(dt.Rows[i]["ID"]);
                            DateTime cdatetime = DBase.DatetimeReturn(dt.Rows[i]["CDATETIME"]);

                            panChat.Controls.Add(C);
                        }
                        catch (Exception ex) { }
                    }
                }

                //ChatItem C2 = new ChatItem();

                //panChat.Controls.Add(C2);

                panChat.VerticalScroll.Value = panChat.VerticalScroll.Maximum;
            }
            catch (Exception ex) { }
        }
Пример #3
0
        private void CODER_DETAIL_Load(object sender, EventArgs e)
        {
            if (ID != "") // Update
            {
                type = 1; // 0 - insert ; 1 - update
                dt   = DHuy.SELECT(TableName, KEYCOL, ID);
            }
            else
            {
                dt = DHuy.SELECT_NEWROW(TableName);
                foreach (DataColumn dc in dt.Columns)
                {
                    if (dc.ColumnName == "CUSERCODE" || dc.ColumnName == "UUSERCODE")
                    {
                        dt.Rows[0][dc.ColumnName] = DBase.UserCodeLogin;
                    }

                    if (dc.ColumnName == "CREATEDBYAGY" || dc.ColumnName == "UPDATEDBYAGY")
                    {
                        // dt.Rows[0][dc.ColumnName] = DBase.AgencyCodeLogin;
                    }


                    string sqlType = dc.DataType.ToString();
                    if (sqlType == "System.DateTime")
                    {
                        dt.Rows[0][dc.ColumnName] = DBase.DatetimeReturn_NowIfNull(dt.Columns[dc.ColumnName]);
                    }
                }
            }

            foreach (Control C in this.Controls)
            {
                if (!C.Name.Contains("edt"))
                {
                    continue;
                }
                String ColName = C.Name.Replace("edt", "");
                string sqlType = dt.Rows[0][ColName].GetType().ToString();

                if (sqlType == "System.DateTime")
                {
                    DateTimePicker D = (DateTimePicker)C;
                    D.Value = DBase.DatetimeReturn(dt.Rows[0][C.Name.Replace("edt", "")]);
                }
                else
                {
//                        if (C.GetType() == typeof(TextPopup))
//                        {
//                            TextPopup T = (TextPopup)C;
//                            T.StopEvent();
//                            T.Text = DBase.StringReturn(dt.Rows[0][C.Name.Replace("edt", "")]);
//                            T.StartEvent();
//                        }
                    if (C.GetType() == typeof(ComboBox))
                    {
                        ComboBox T = (ComboBox)C;
                        T.Text = DBase.StringReturn(dt.Rows[0][C.Name.Replace("edt", "")]);
                    }

                    else if (C.GetType() == typeof(CheckBox))
                    {
                        CheckBox T = (CheckBox)C;
                        T.Checked = DBase.BoolReturn(dt.Rows[0][C.Name.Replace("edt", "")]);
                    }


                    else if (C.GetType() == typeof(PictureBox))
                    {
                        PictureBox T = (PictureBox)C;
                        T.Click += new System.EventHandler(this.edtIMAGE_Click);
                        try
                        {
                            System.IO.MemoryStream ms = new System.IO.MemoryStream((Byte[])(dt.Rows[0][C.Name.Replace("edt", "")]));
                            T.Image = Image.FromStream(ms);
                            //  ms.Dispose();
                        }
                        catch (Exception ex) { }
                    }

                    else
                    {
                        C.Text = DBase.StringReturn(dt.Rows[0][C.Name.Replace("edt", "")]);
                    }
                }
            }
            //Asign Value Change Event
            foreach (Control C in this.Controls)
            {
                C.TextChanged += new System.EventHandler(this.TextChange);
            }

            //Asign Checkchange Event
            foreach (Control C in this.Controls)
            {
                if (C.GetType() == typeof(CheckBox))
                {
                    ((CheckBox)C).CheckedChanged += new System.EventHandler(this.CheckedChanged);
                }
            }

            //Remove Readonly
            foreach (DataColumn col in dt.Columns)
            {
                col.ReadOnly = false;
            }
        }