Beispiel #1
0
        //редактирование
        private void radGridView1_RowsChanging(object sender, GridViewCollectionChangingEventArgs e)
        {
            if (_status)
            {
                _status = false;
                return;
            }
            var commandServer = new CommandServer();
            var commandClient = new CommandClient();

            if (e.Action == NotifyCollectionChangedAction.ItemChanging)
            {
                var line = (GridViewRowInfo)e.NewItems[0];

                if (line.Cells[0].Value != null)
                {
                    if (e.PropertyName == "ФИО")
                    {
                        var    parameters = "'" + line.Cells[1].Value.ToString() + "','";
                        string text       = null;

                        if (e.NewValue.ToString().Split(' ').Length == 3)
                        {
                            text = commandClient.CharTo(e.NewValue.ToString().Split(' ')[0]) + " " +
                                   commandClient.CharTo(e.NewValue.ToString().Split(' ')[1]) + " " +
                                   commandClient.CharTo(e.NewValue.ToString().Split(' ')[2]);
                        }
                        else
                        {
                            text = e.NewValue.ToString();
                        }
                        parameters += text + "'";

                        var returnSqlServer = commandServer.ExecReturnServer("socRabotnik_edit", parameters);
                        if (returnSqlServer[1] == "0")
                        {
                            e.Cancel = true;
                        }
                        //loadGridSoc();
                        //LoadGridSoc();
                        AlertOperation("socRabotnik_edit " + line.Cells[1].Value, returnSqlServer);
                    }
                }
            }
        }
Beispiel #2
0
        private void radGridView5_UserAddingRow(object sender, GridViewRowCancelEventArgs e)
        {
            if (_status)
            {
                _status = false;
                return;
            }

            if (e.Rows[0].Cells[1].Value == null || e.Rows[0].Cells[1].Value.ToString() == "")
            {
                AlertOperation("speziolist_add", new string[] { "Не указано ФИО.", "1" });
                e.Cancel = true;
                return;
            }
            var    commandServer = new CommandServer();
            var    commandClient = new CommandClient();
            string fio;
            var    line = e.Rows[0].Cells[1].Value.ToString();

            if (e.Rows[0].Cells[1].Value.ToString().Split(' ').Length == 3)
            {
                fio = commandClient.CharTo(e.Rows[0].Cells[1].Value.ToString().Split(' ')[0]) + " " +
                      commandClient.CharTo(e.Rows[0].Cells[1].Value.ToString().Split(' ')[1]) + " " +
                      commandClient.CharTo(e.Rows[0].Cells[1].Value.ToString().Split(' ')[2]);
            }
            else
            {
                fio = e.Rows[0].Cells[1].Value.ToString();
            }

            var parameters      = "'" + fio + "','0'";
            var returnSqlServer = commandServer.ExecNoReturnServer("speziolist_add", parameters);

            if (returnSqlServer[1] == "0")
            {
                e.Cancel = true;
            }

            AlertOperation("socRabotnik_add " + parameters, returnSqlServer);
            radGridView5.DataSource = _bindingSource_personel;
        }