Пример #1
0
        // 设置文本框的默认配置
        private void initControlDefConfig()
        {
            string timeStr = DateTime.Now.ToUniversalTime().Ticks.ToString();

            // 文本框姓名
            this.Name             = EnumUtils.GetDescription(DefaultNameEnum.TEXTBOX_NAME_DEF) + timeStr;
            this.TabStop          = true;
            this.AllowDrop        = true;
            this.BorderStyle      = BorderStyle.None;
            this.Font             = MainTextBConfig.TEXTBOX_FONT;
            this.ReadOnly         = TextBoxDataLibcs.TEXTBOX_READ_ONLY_DEF;
            this.HideSelection    = false;
            this.Location         = new Point(0, 0);
            this.MaxLength        = 999999999;
            this.Multiline        = true;
            this.ShortcutsEnabled = false;
            this.ScrollBars       = ScrollBars.Both;
            this.Anchor           = AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Top | AnchorStyles.Bottom;
            this.TabIndex         = 0;
            this.WordWrap         = MainTextBConfig.AUTO_WORDWRAP;
            this.AcceptsTab       = false;
            this.TextPadding      = new Padding(3);
            // 将文件默认编码写入到文本框tag数据中
            TextBoxUtils.TextBoxAddTag(this, TextBoxTagKey.TEXTBOX_TAG_KEY_ECODING, TextBoxDataLibcs.TEXTBOX_ECODING_DEF);
            // 消除控件重绘闪烁
            ControlsUtils.ClearRedrawFlashing(this);
        }
Пример #2
0
        /// <summary>
        /// 实例化文件保存对话框保存文本
        /// </summary>
        /// <param name="t">要保存内容的文本框</param>
        /// <returns></returns>
        public static object saveFileMethod(TextBox t)
        {
            SaveFileDialog newSaveFile          = new SaveFileDialog();
            Dictionary <string, object> textTag = TextBoxUtils.GetTextTagToMap(t);

            newSaveFile.RestoreDirectory = false;
            newSaveFile.ValidateNames    = true;
            newSaveFile.DefaultExt       = "txt";
            if (t != null && t.Parent != null)
            {
                newSaveFile.FileName = t.Parent.Text;
            }
            newSaveFile.Filter = "文本文档(*.txt)|*.txt|所有文件(*.*)|*.*";
            // 获取文本框保存的Ecoding
            Encoding encoding = Encoding.Default;

            if (textTag.ContainsKey(TextBoxTagKey.TEXTBOX_TAG_KEY_ECODING) && textTag[TextBoxTagKey.TEXTBOX_TAG_KEY_ECODING] is Encoding)
            {
                encoding = (Encoding)textTag[TextBoxTagKey.TEXTBOX_TAG_KEY_ECODING];
            }
            //判断是否点击确定
            if (newSaveFile.ShowDialog() == DialogResult.OK)
            {
                string path = newSaveFile.FileName;
                // 调用方法写入文件内容
                FileUtils.FileWrite.WriteFile(path, t.Text, encoding);
                // 将保存路径加入到文本框的Tag属性
                TextBoxUtils.TextBoxAddTag(t, TextBoxTagKey.SAVE_FILE_PATH, newSaveFile.FileName);
                // 监听文件变化并弹窗提醒 传入的文本框为null则开启一个新标签
                TextBox tempTextB = t != null? t : MainTabControlUtils.GetNewPageTextBox();
                FileUtils.SetTextBoxValByPath(tempTextB, path, encoding);
            }
            return(newSaveFile);
        }
Пример #3
0
        public void PutTestAddAtNegativePosition()
        {
            int    cursorPosition = -8;
            string result         = TextBoxUtils.Put("Current content", ref cursorPosition, "98");

            Assert.AreEqual(result.CompareTo("Current content98"), 0);
        }
Пример #4
0
        /// <summary>
        /// 将文本框打开的文件路径显示到文本框的父容器下目录下
        /// </summary>
        private void setParentTextByFileName()
        {
            TextBox t = this;
            // 获取文本框的父容器
            Control con = t.Parent;

            // 判断父容器是否为TabPage
            if (con.GetType().Equals(typeof(TabPage)))
            {
                ControlsUtils.AsynchronousMethod(t, 300, delegate {
                    // 判断Tag中是否存在保存路径
                    if (TextBoxUtils.GetTextTagToMap(t).ContainsKey(TextBoxTagKey.SAVE_FILE_PATH))
                    {
                        string filepath  = TextBoxUtils.GetTextTagToMap(t)[TextBoxTagKey.SAVE_FILE_PATH].ToString();
                        TabPage page     = (TabPage)t.Parent;
                        string[] pathArr = FileUtils.GetPathArr(filepath);
                        page.ResetText();

                        // 设置标签文本
                        page.Text = pathArr[1];
                        // 设置提示文本
                        page.ToolTipText = filepath;
                    }
                });
            }
        }
Пример #5
0
        private void btnRegionAddAdd_Click(object sender, EventArgs e)
        {
            try
            {
                //Add a region to the database, gets data from form components
                string query = "START TRANSACTION; " +
                               "INSERT INTO toimintaalue(toimintaalue_id,nimi) " +
                               "VALUES(default,'" +
                               TextBoxUtils.ModifyInput(tbRegionAddRegionName.Text, 40) + "');" +
                               "COMMIT;";

                try
                {
                    ConnectionUtils.OpenConnection();
                    MySqlCommand command = new MySqlCommand(query, ConnectionUtils.connection);
                    command.ExecuteNonQuery();
                    ConnectionUtils.CloseConnection();
                    this.Close();
                }
                catch (Exception ex)
                {
                    //Incase of database-connection problems
                    ConnectionUtils.CloseConnection();
                    MessageBox.Show("Virhe tietojen syöttämisessä tietokantaan. Tarkista kenttien tiedot. Lisätietoja: " + ex.Message.ToString());
                }
            }
            catch (Exception ex)
            {
                //Incase of variable conversion problems
                ConnectionUtils.CloseConnection();
                MessageBox.Show("Virhe tietojen muuntamisessa. Tarkista kenttien tiedot. Lisätietoja: " + ex.Message.ToString());
            }
        }
 // 设置状态栏的编码
 private object setToolSatrtEcoding(Control con)
 {
     if (con == null)
     {
         MessageBox.Show("无法获取控件");
     }
     // 获取文本框
     if (con is TextBox)
     {
         TextBox t = (TextBox)con;
         // 开辟新线程执行方法
         ControlsUtils.AsynchronousMethod(t, 300, delegate {
             Dictionary <string, object> tag = TextBoxUtils.GetTextTagToMap(t);
             Encoding ecoding = TextBoxDataLibcs.TEXTBOX_ECODING_DEF;
             // 获取文本框中Tag中存的编码
             if (tag.ContainsKey(TextBoxTagKey.TEXTBOX_TAG_KEY_ECODING))
             {
                 ecoding = (Encoding)TextBoxUtils.GetTextTagToMap(t)[TextBoxTagKey.TEXTBOX_TAG_KEY_ECODING];
             }
             // 全局单例控件工厂
             Dictionary <string, Control> single = ControlCacheFactory.getSingletonCache();
             if (single.ContainsKey(EnumUtils.GetDescription(DefaultNameEnum.TOOL_START)))
             {
                 // 状态栏
                 ToolStrip toolStrip = (ToolStrip)single[EnumUtils.GetDescription(DefaultNameEnum.TOOL_START)];
                 // 获取编码Item
                 ToolStripItem labEcoding = toolStrip.Items[StrutsStripDataLib.ItemName.编码];
                 labEcoding.Text          = ecoding.BodyName.ToUpper();
             }
         });
     }
     return(null);
 }
 // 将总行数与总字符数赋值给状态栏
 private void setRowChars(Control con)
 {
     if (con == null)
     {
         MessageBox.Show("无法获取控件");
     }
     if (con is TextBox)  // 获取文本框
     {
         TextBox t = (TextBox)con;
         // 开辟新线程执行方法
         ControlsUtils.AsynchronousMethod(this, 1, delegate {
             ToolStripLabel lable1 = (ToolStripLabel)this.Items[StrutsStripDataLib.ItemName.总行数];
             ToolStripLabel lable2 = (ToolStripLabel)this.Items[StrutsStripDataLib.ItemName.总字符数];
             string tag1           = lable1.Tag != null?lable1.Tag.ToString() + ":":"";
             string tag2           = lable2.Tag != null?lable2.Tag.ToString() + ":":"";
             lable1.Text           = tag1 + TextBoxUtils.GetTextBoxTotalRow(t).ToString();
             lable2.Text           = tag2 + TextBoxUtils.GetTextBoxChars(t, false).ToString();
         });
     }
     else if (con is DataGridView)   // 表格
     {
         DataGridView g = (DataGridView)con;
         // 开辟新线程执行方法
         ControlsUtils.AsynchronousMethod(this, 1, delegate {
             ToolStripLabel lable1 = (ToolStripLabel)this.Items[StrutsStripDataLib.ItemName.总行数];
             ToolStripLabel lable2 = (ToolStripLabel)this.Items[StrutsStripDataLib.ItemName.总字符数];
             string tag1           = lable1.Tag != null?lable1.Tag.ToString() + ":":"";
             string tag2           = lable2.Tag != null?lable2.Tag.ToString() + ":":"";
             lable1.Text           = tag1 + g.RowCount.ToString();
             lable2.Text           = tag2 + DataGridViewUtilMet.getDatatabelSelText(g, true)
                                     .Replace("\t", "").Replace(Environment.NewLine, "").Length.ToString();
         });
     }
 }
Пример #8
0
        /// <summary>
        /// 将文本框打开的文件路径显示到文本框的父容器下目录下
        /// </summary>
        /// <param name="t"></param>
        public static object setParentTextByFileName(Dictionary <Type, object> data)
        {
            TextBox t = (TextBox)data[typeof(TextBox)];
            // 获取文本框的父容器
            Control con = t.Parent;

            // 判断父容器是否为TabPage
            if (con.GetType().Equals(typeof(TabPage)))
            {
                ControlsUtils.AsynchronousMethod(t, 300, delegate {
                    // 判断Tag中是否存在保存路径
                    if (TextBoxUtils.GetTextTagToMap(t).ContainsKey(TextBoxTagKey.SAVE_FILE_PATH))
                    {
                        string filepath  = TextBoxUtils.GetTextTagToMap(t)[TextBoxTagKey.SAVE_FILE_PATH].ToString();
                        TabPage page     = (TabPage)t.Parent;
                        string[] pathArr = FileUtils.GetPathArr(filepath);
                        page.ResetText();

                        // 设置标签文本
                        page.Text = pathArr[1];
                        // 设置提示文本
                        page.ToolTipText = filepath;
                    }
                });
            }
            return(null);
        }
Пример #9
0
        private void initControls()
        {
            TextBoxUtils.initTextBox(txtSystemName, "treasure_def", "system_name");
            TextBoxUtils.initTextBox(txtSystemDescription, "treasure_def", "system_description");

            initTablesGrid();
        }
Пример #10
0
        private void initControls()
        {
            TextBoxUtils.initTextBox(txtSystemName, "shop_def", "system_name");

            initItemTypesGrid();
            initItemsGrid();
            initAbilitiesGrid();
        }
        private void initControls()
        {
            TextBoxUtils.initTextBox(txtSystemName, "space_effect_def", "system_name");
            TextBoxUtils.initTextBox(txtDisplayName, "space_effect_def", "display_name");

            linkSummoningNpc.SystemType = EditorSystemType.Npc;
            linkEffect.SystemType       = EditorSystemType.Effect;
        }
Пример #12
0
        private void initControls()
        {
            TextBoxUtils.initTextBox(txtSystemName, "barrier_def", "system_name");

            linkLock.SystemType = EditorSystemType.Item;
            linkTrap.SystemType = EditorSystemType.Item;
            linkKey.SystemType  = EditorSystemType.Item;
        }
Пример #13
0
        private void initControls()
        {
            TextBoxUtils.initTextBox(txtSystemName, "archetype_def", "system_name");
            TextBoxUtils.initTextBox(txtDisplayName, "archetype_def", "display_name");
            TextBoxUtils.initTextBox(txtDisplayDescription, "archetype_def", "display_description");

            initAbilitiesGrid();
            initStatsGrid();
        }
Пример #14
0
        private void initControls()
        {
            TextBoxUtils.initTextBox(txtSystemName, "effect_def", "system_name");
            TextBoxUtils.initTextBox(txtDisplayName, "effect_def", "display_name");
            TextBoxUtils.initTextBox(txtDisplayDescription, "effect_def", "display_description");
            radInstant.Checked = true;

            ComboUtils.fillCombo(cboEffectType, "ref_effect_type", "name", "ref_effect_type_id", 0);
            cboEffectType.SelectedText = "Health Change";
        }
Пример #15
0
        private void initControls()
        {
            TextBoxUtils.initTextBox(txtSystemName, "spawn_def", "system_name");
            ComboUtils.fillCombo(cboSpawnType, "ref_spawn_type", "name", "ref_spawn_type_id", 0);

            initNpcsGrid();
            initItemsGrid();
            initSpacesGrid();
            initAccessGrid();
        }
Пример #16
0
        // 智能选择
        private void intelligentSelectText(TextBox t)
        {
            int mouseIndex = t.SelectionStart;
            // 是否处于行的末尾
            bool isMouseLineEnd = TextBoxUtils.IsPointLineEnd(t, mouseIndex);

            if (isMouseLineEnd)
            {
                // 选中整行
                int i = t.GetFirstCharIndexOfCurrentLine();
                t.Select(i, mouseIndex - i);
            }
            else
            {
                int headMatch = 0;
                int tailMatch = 0;
                for (int i = 1; i <= t.TextLength; i++)
                {
                    if (headMatch.Equals(0))
                    {
                        if (t.SelectionStart - i >= 0)
                        {
                            if (Regex.IsMatch(t.Text[t.SelectionStart - i].ToString(), @"\W"))
                            {
                                headMatch = (t.SelectionStart - i) + 1;
                            }
                        }
                        else
                        {
                            headMatch = 0;
                        }
                    }
                    if (tailMatch.Equals(0))
                    {
                        if (t.SelectionStart + i < t.TextLength)
                        {
                            if (Regex.IsMatch(t.Text[t.SelectionStart + i].ToString(), @"\W"))
                            {
                                tailMatch = t.SelectionStart + i;
                            }
                        }
                        else
                        {
                            tailMatch = (t.SelectionStart + i);
                        }
                    }
                    if (!headMatch.Equals(0) && !tailMatch.Equals(0))
                    {
                        break;
                    }
                }
                t.SelectionStart  = headMatch;
                t.SelectionLength = tailMatch - t.SelectionStart;
            }
        }
Пример #17
0
        // 双击选中文本
        private void doubleClickSelectText()
        {
            int mouseIndex = SelectionStart;
            // 是否处于行的末尾
            bool isMouseLineEnd = TextBoxUtils.IsPointLineEnd(this, mouseIndex);

            if (isMouseLineEnd)
            {
                // 选中整行
                int i = GetFirstCharIndexOfCurrentLine();
                Select(i, mouseIndex - i);
            }
            else
            {
                int headMatch = 0;
                int tailMatch = 0;
                for (int i = 1; i <= TextLength; i++)
                {
                    if (headMatch.Equals(0))
                    {
                        if (SelectionStart - i >= 0)
                        {
                            if (Regex.IsMatch(Text[SelectionStart - i].ToString(), @"\W"))
                            {
                                headMatch = (SelectionStart - i) + 1;
                            }
                        }
                        else
                        {
                            headMatch = 0;
                        }
                    }
                    if (tailMatch.Equals(0))
                    {
                        if (SelectionStart + i < TextLength)
                        {
                            if (Regex.IsMatch(Text[SelectionStart + i].ToString(), @"\W"))
                            {
                                tailMatch = SelectionStart + i;
                            }
                        }
                        else
                        {
                            tailMatch = (SelectionStart + i);
                        }
                    }
                    if (!headMatch.Equals(0) && !tailMatch.Equals(0))
                    {
                        break;
                    }
                }
                SelectionStart  = headMatch;
                SelectionLength = tailMatch - SelectionStart;
            }
        }
Пример #18
0
        /// <summary>
        /// 将文本框编码设置为指定编码格式
        /// </summary>
        private void setTextByEncoding()
        {
            if (textBox == null)
            {
                MessageBox.Show("要操作的文本框为NULL");
            }
            // 获取起始选中位置和选中长度
            int index  = textBox.SelectionStart;
            int selLen = textBox.SelectionLength;
            // 文本框的Tag数据
            Dictionary <string, object> tag = TextBoxUtils.GetTextTagToMap(textBox);
            // 获取选中的项的编码页码
            int codingInt = Encoding.UTF8.CodePage;

            if (coding_set.SelectedValue != null)
            {
                try {
                    codingInt = int.Parse(coding_set.SelectedValue.ToString());
                } catch (Exception ee) {
                    MessageBox.Show("选中内容无法转化为编码,将使用默认编码" + ee);
                }
            }
            // 获取选择项的编码
            Encoding coding = Encoding.GetEncoding(codingInt);
            // 获取文本框的文本
            string text = null;

            if (tag.ContainsKey(TextBoxTagKey.SAVE_FILE_PATH))
            {
                string path = tag[TextBoxTagKey.SAVE_FILE_PATH].ToString();
                if (FileUtils.isFileUrl(path))
                {
                    text = FileUtils.FileRead.Read(path, coding);
                }
            }
            if (text == null)
            {
                text = textBoxBackup;
            }
            if (text == null || text.Length == 0)
            {
                return;
            }
            // 将文本框的文本设置为指定编码格式
            byte[] textBoxBytes = textCoding.GetBytes(text);
            byte[] asciiBytes   = Encoding.Convert(textCoding, coding, textBoxBytes);
            textBox.Text = coding.GetString(asciiBytes);

            // 恢复文本框的起始位置和选中长度
            textBox.SelectionStart  = index;
            textBox.SelectionLength = selLen;
            // 设置保存在Tag数据中的文本框编码
            TextBoxUtils.TextBoxAddTag(textBox, TextBoxTagKey.TEXTBOX_TAG_KEY_ECODING, coding);
        }
Пример #19
0
        private void initControls()
        {
            TextBoxUtils.initTextBox(txtSystemName, "zone_def", "system_name");
            TextBoxUtils.initTextBox(txtDisplayName, "zone_def", "display_name");
            TextBoxUtils.initTextBox(txtDescription, "zone_def", "display_description");
            TextBoxUtils.initTextBox(txtAuthor, "zone_def", "author");

            initSpacesGrid();
            initAccessLevelsGrid();
            initSpawnsGrid();
        }
Пример #20
0
        private void initControls()
        {
            TextBoxUtils.initTextBox(txtSystemName, "space_def", "system_name");
            TextBoxUtils.initTextBox(txtDisplayName, "space_def", "display_name");
            TextBoxUtils.initTextBox(txtDescription, "space_def", "display_description");

            linkAccessLevel.SystemType = EditorSystemType.AccessLevel;

            initExitGrid();
            initNpcGrid();
            initItemGrid();
            initEffectsGrid();
        }
Пример #21
0
        /// <summary>
        /// 撤销缓存区文本
        /// </summary>
        /// <param name="t"></param>
        /// <param name="keys"></param>
        public static object cancelTextBoxCache(Dictionary <Type, object> data)
        {
            TextBox t = (TextBox)data[typeof(TextBox)];

            // 非只读才能撤销
            if (!t.ReadOnly)
            {
                // 将文本框置于撤销状态
                TextBoxUtils.TextBoxAddTag(t, TextBoxTagKey.TEXTBOX_IS_CANCEL, true);
                TextBoxCache.cancelCache(t);
            }

            return(null);
        }
Пример #22
0
        /// <summary>
        /// 恢复缓存区文本
        /// </summary>
        /// <param name="t"></param>
        public static object restoreTextBoxCache(Dictionary <Type, object> data)
        {
            TextBox t = (TextBox)data[typeof(TextBox)];

            // 非只读才能撤销
            if (!t.ReadOnly)
            {
                // 将文本框置于恢复状态
                TextBoxUtils.TextBoxAddTag(t, TextBoxTagKey.TEXTBOX_IS_RESTORE, true);
                TextBoxCache.restoreCache(t);
            }

            return(null);
        }
Пример #23
0
        private void initControls()
        {
            TextBoxUtils.initTextBox(txtSystemName, "statistic_def", "system_name");
            TextBoxUtils.initTextBox(txtDisplayName, "statistic_def", "display_name");
            TextBoxUtils.initTextBox(txtDisplayDescription, "statistic_def", "display_description");

            TagUtils.fillCheckedList(lstStatTags, "StatisticGroupTags");
            ComboUtils.fillCombo(cboStatType, "ref_stat_type", "name", "ref_stat_type_id", 0);

            lblAmalgam.Visible       = false;
            gridAmalgamStats.Visible = false;

            initAmalgamStatGrid();
            initRequiredStatGrid();
        }
Пример #24
0
        /// <summary>
        /// 将文本框的编码赋值到label中
        /// </summary>
        private void textCodinCopyLab()
        {
            Dictionary <string, object> textDic = TextBoxUtils.GetTextTagToMap(textBox);

            if (textDic.ContainsKey(TextBoxTagKey.TEXTBOX_TAG_KEY_ECODING))
            {
                Encoding coding = (Encoding)textDic[TextBoxTagKey.TEXTBOX_TAG_KEY_ECODING];
                textCoding      = coding;
                get_coding.Text = coding.BodyName.ToUpper();
            }
            else
            {
                get_coding.Text = Encoding.UTF8.BodyName.ToUpper();
                textCoding      = Encoding.UTF8;
            }
        }
Пример #25
0
        private void btnModifyCottageModify_Click(object sender, EventArgs e)
        {
            //Make sure the data should be modified
            DialogResult result = MessageBox.Show("Haluatko varmasti muuttaa valitun mökin tietoja?", "Muuta mökin tietoja",
                                                  MessageBoxButtons.YesNo, MessageBoxIcon.Information);

            if (result == DialogResult.Yes)
            {
                try
                {
                    //Updates cottages information in the database. Gets data from form components, cottage is uniquely identified by cottageID, which can't be modified
                    string query = "START TRANSACTION; " +
                                   "UPDATE mokki " +
                                   "SET toimintaalue_id=" + RegionUtils.RegionNameToIndex(cbModifyCottageRegion.Text) +
                                   ",postinro='" + TextBoxUtils.ModifyInput(tbModifyCottagePostNum.Text, 5) +
                                   "',mokkinimi='" + TextBoxUtils.ModifyInput(tbModifyCottageName.Text, 45) +
                                   "',katuosoite='" + TextBoxUtils.ModifyInput(tbModifyCottageStreet.Text, 45) + "'," +
                                   "kuvaus='" + TextBoxUtils.ModifyInput(tbModifyCottageDescription.Text, 500) +
                                   "',henkilomaara=" + nudModifyCottageCapacity.Value +
                                   " ,varustelu='" + TextBoxUtils.ModifyInput(cbModifyCottageEquipment.Text, 100) +
                                   "', hinta=" + Convert.ToDouble(nudModifyCottagePrice.Value) + " " +
                                   "WHERE mokki_id=" + Convert.ToInt32(lblModifyCottageID.Text) + "; " +
                                   "COMMIT;";
                    try
                    {
                        ConnectionUtils.OpenConnection();
                        MySqlCommand command = new MySqlCommand(query, ConnectionUtils.connection);
                        command.ExecuteNonQuery();
                        ConnectionUtils.CloseConnection();
                        this.Close();
                    }
                    catch (Exception ex)
                    {
                        //Incase of database-connection problems
                        ConnectionUtils.CloseConnection();
                        MessageBox.Show("Virhe tietojen syöttämisessä tietokantaan. Tarkista kenttien tiedot, ja yritä uudelleen myöhemmin. Lisätietoja virheestä: "
                                        + ex.Message.ToString());
                    }
                }
                catch (Exception ex)
                {
                    //Incase of variable conversion problems
                    ConnectionUtils.CloseConnection();
                    MessageBox.Show("Virhe tietojen muuntamisessa. Onhan kaikkien kenttien syötteet oikein? Lisätietoja virheestä: " + ex.Message.ToString());
                }
            }
        }
Пример #26
0
        private void btnModifyServiceModify_Click(object sender, EventArgs e)
        {
            //Make sure the data should be modified
            DialogResult result = MessageBox.Show("Haluatko varmasti muuttaa valitun palvelun tietoja?", "Muuta palvelun tietoja",
                                                  MessageBoxButtons.YesNo, MessageBoxIcon.Information);

            if (result == DialogResult.Yes)
            {
                try
                {
                    //Updates services information in the database. Gets data from form components, service is uniquely identified by serviceID, which can't be modified
                    string query = "START TRANSACTION; " +
                                   "UPDATE palvelu " +
                                   "SET toimintaalue_id=" + RegionUtils.RegionNameToIndex(cbModifyServiceRegion.Text) +
                                   ",nimi='" + TextBoxUtils.ModifyInput(tbModifyServiceName.Text, 40) +
                                   "',tyyppi=" + Convert.ToInt32(tbModifyServiceType.Text) +
                                   ",kuvaus='" + TextBoxUtils.ModifyInput(tbModifyServiceDescription.Text, 40) + "'," +
                                   "hinta=" + Convert.ToDouble(nudModifyServicePrice.Value) +
                                   ",alv=" + Convert.ToDouble(nudModifyServiceVAT.Value) + " " +
                                   "WHERE palvelu_id=" + Convert.ToInt32(lblModifyServiceID.Text) + "; " +
                                   "COMMIT;";
                    try
                    {
                        ConnectionUtils.OpenConnection();
                        MySqlCommand command = new MySqlCommand(query, ConnectionUtils.connection);
                        command.ExecuteNonQuery();
                        ConnectionUtils.CloseConnection();
                        this.Close();
                    }
                    catch (Exception ex)
                    {
                        //Incase of database-connection problems
                        ConnectionUtils.CloseConnection();
                        MessageBox.Show("Virhe tietojen syöttämisessä tietokantaan. Tarkista kenttien tiedot, ja yritä uudelleen myöhemmin. Lisätietoja virheestä: "
                                        + ex.Message.ToString());
                    }
                }
                catch (Exception ex)
                {
                    //Incase of variable conversion problems
                    ConnectionUtils.CloseConnection();
                    MessageBox.Show("Virhe tietojen muuntamisessa. Onhan kaikkien kenttien syötteet oikein? Lisätietoja virheestä: " + ex.Message.ToString());
                }
            }
        }
Пример #27
0
 private void checkControls()
 {
     Debug.WriteLine("checkControls");
     if (this.pwChangerWorker != null && this.pwChangerWorker.IsRunning)
     {
         return;
     }
     if (this.maskedTextBoxNewPassword.UseSystemPasswordChar && this.passwordsMatch() ||
         !this.maskedTextBoxNewPassword.UseSystemPasswordChar && TextBoxUtils.HasText(this.maskedTextBoxNewPassword))
     {
         this.buttonChangePassword.Enabled = true;
     }
     else
     {
         this.buttonChangePassword.Enabled = false;
     }
     this.maskedTextBoxRepeatNewPassword.Enabled = this.maskedTextBoxNewPassword.UseSystemPasswordChar;
 }
Пример #28
0
 /// <summary>
 /// 撤销缓存区文本
 /// </summary>
 /// <param name="t"></param>
 /// <param name="keys"></param>
 public static object cancelTextBoxCache(Dictionary <Type, object> data)
 {
     if (data.ContainsKey(typeof(TextBox)) && data[typeof(TextBox)] is TextBox)
     {
         TextBox t = (TextBox)data[typeof(TextBox)];
         // 非只读状态才能撤销
         if (!t.ReadOnly)
         {
             // 将文本框置于撤销状态
             TextBoxUtils.TextBoxAddTag(t, TextBoxTagKey.TEXTBOX_IS_CANCEL, true);
             TextBoxCache.cancelCache(t);
         }
     }
     else
     {
         MessageBox.Show("无法获取文本框");
     }
     return(null);
 }
Пример #29
0
 /// <summary>
 /// 恢复缓存区文本
 /// </summary>
 /// <param name="t"></param>
 public static object restoreTextBoxCache(Dictionary <Type, object> data)
 {
     if (data.ContainsKey(typeof(TextBox)) && data[typeof(TextBox)] is TextBox)
     {
         TextBox t = (TextBox)data[typeof(TextBox)];
         // 非只读状态才能恢复
         if (!t.ReadOnly)
         {
             // 将文本框置于恢复状态
             TextBoxUtils.TextBoxAddTag(t, TextBoxTagKey.TEXTBOX_IS_RESTORE, true);
             TextBoxCache.restoreCache(t);
         }
     }
     else
     {
         MessageBox.Show("无法获取文本框");
     }
     return(null);
 }
 // 将当前的行列数赋值给状态栏
 private void setRowColumn(Control con)
 {
     if (con == null)
     {
         MessageBox.Show("无法获取控件");
     }
     if (con is TextBox)  // 获取文本框
     {
         TextBox t = (TextBox)con;
         // 开辟新线程执行方法
         ControlsUtils.AsynchronousMethod(this, 1, delegate {
             ToolStripLabel lable1 = (ToolStripLabel)this.Items[StrutsStripDataLib.ItemName.行列数];
             int[] val             = TextBoxUtils.GetTextBoxRowColumn(t);
             string tag1           = lable1.Tag != null?lable1.Tag.ToString():"";
             if (val != null)
             {
                 //将行与列赋值给label
                 lable1.Text = tag1.Replace("{1}", val[0].ToString())
                               .Replace("{2}", val[1].ToString());
             }
         });
     }
     else if (con is DataGridView)   // 表格
     {
         DataGridView g = (DataGridView)con;
         // 开辟新线程执行方法
         ControlsUtils.AsynchronousMethod(this, 1, delegate {
             ToolStripLabel lable1 = (ToolStripLabel)this.Items[StrutsStripDataLib.ItemName.行列数];
             int[] val             = new int[] {
                 g.SelectedCells.Count > 0? g.SelectedCells[0].RowIndex + 1: 0,
                 g.SelectedCells.Count > 0? g.SelectedCells[0].ColumnIndex + 1: 0
             };
             string tag1 = lable1.Tag != null?lable1.Tag.ToString():"";
             if (val != null)
             {
                 //将行与列赋值给label
                 lable1.Text = tag1.Replace("{1}", val[0].ToString())
                               .Replace("{2}", val[1].ToString());
             }
         });
     }
 }