private SiteMapNode SiteMapResolve(object sender, SiteMapResolveEventArgs e)
		{
			var currentNode = e.Provider.CurrentNode.Clone(true);
			if (currentNode.Url.EndsWith("/managep.aspx"))
				currentNode.ParentNode.Url += e.Context.Request["cc"];
			else if (currentNode.Url.EndsWith("/SenderProperties.aspx")) {
				uint firmCode;
				using (var connection = new MySqlConnection(Literals.GetConnectionString())) {
					connection.Open();
					var command = new MySqlCommand(@"
select firmcode 
from ordersendrules.order_send_rules osr
where osr.id = ?ruleId
", connection);
					command.Parameters.AddWithValue("?RuleId", e.Context.Request["RuleId"]);
					firmCode = Convert.ToUInt32(command.ExecuteScalar());
				}
				currentNode.ParentNode.Url += "?cc=" + firmCode;
				currentNode.ParentNode.ParentNode.Url += firmCode;
			}
			else if (currentNode.Url.EndsWith("/EditRegionalInfo.aspx")) {
				uint firmCode;
				using (var connection = new MySqlConnection(Literals.GetConnectionString())) {
					connection.Open();
					var command = new MySqlCommand(@"
SELECT FirmCode
FROM usersettings.regionaldata rd
WHERE RowID = ?Id", connection);
					command.Parameters.AddWithValue("?Id", Convert.ToUInt32(e.Context.Request["id"]));
					firmCode = Convert.ToUInt32(command.ExecuteScalar());
				}
				currentNode.ParentNode.Url += "?cc=" + firmCode;
				currentNode.ParentNode.ParentNode.Url += firmCode;
			}
			else if (currentNode.Url.EndsWith("/managecosts.aspx")) {
				uint firmCode;
				using (var connection = new MySqlConnection(Literals.GetConnectionString())) {
					connection.Open();
					var command = new MySqlCommand(@"
SELECT FirmCode
FROM usersettings.PricesData pd
WHERE PriceCode = ?Id", connection);
					command.Parameters.AddWithValue("?Id", Convert.ToUInt32(e.Context.Request["pc"]));
					firmCode = Convert.ToUInt32(command.ExecuteScalar());
				}
				currentNode.ParentNode.Url += "?cc=" + firmCode;
				currentNode.ParentNode.ParentNode.Url += firmCode;
			}
			return currentNode;
		}
        protected void Save_Click(object sender, EventArgs e)
        {
            ProcessChanges();
            using (var connection = new MySqlConnection(Literals.GetConnectionString())) {
                connection.Open();
                var transaction = connection.BeginTransaction(IsolationLevel.RepeatableRead);
                try {
                    var dataAdapter = new MySqlDataAdapter("", connection);
                    dataAdapter.InsertCommand             = new MySqlCommand(@"
insert into ordersendrules.handler_properties(name, value, OrderSendRuleId)
values (?name, ?value, ?ruleId);", connection);
                    dataAdapter.InsertCommand.Transaction = transaction;
                    dataAdapter.InsertCommand.Parameters.Add("?Name", MySqlDbType.VarString, 0, "Name");
                    dataAdapter.InsertCommand.Parameters.Add("?Value", MySqlDbType.VarString, 0, "Value");
                    dataAdapter.InsertCommand.Parameters.AddWithValue("?RuleId", RuleId);

                    dataAdapter.DeleteCommand             = new MySqlCommand(@"
delete from ordersendrules.handler_properties
where id = ?id;", connection);
                    dataAdapter.DeleteCommand.Transaction = transaction;
                    dataAdapter.DeleteCommand.Parameters.Add("?Id", MySqlDbType.Int32, 0, "Id");

                    dataAdapter.UpdateCommand             = new MySqlCommand(@"
update ordersendrules.handler_properties
set name = ?name,
	value = ?value
where id = ?id;", connection);
                    dataAdapter.UpdateCommand.Transaction = transaction;
                    dataAdapter.UpdateCommand.Parameters.Add("?Id", MySqlDbType.Int32, 0, "Id");
                    dataAdapter.UpdateCommand.Parameters.Add("?Name", MySqlDbType.VarString, 0, "Name");
                    dataAdapter.UpdateCommand.Parameters.Add("?Value", MySqlDbType.VarString, 0, "Value");

                    dataAdapter.Update(Data.Tables["Properties"]);

                    transaction.Commit();
                }
                catch (Exception) {
                    if (transaction != null)
                    {
                        transaction.Rollback();
                    }

                    throw;
                }
            }

            GetData();
            ConnectDataSource();
            DataBind();
        }
示例#3
0
    protected void SaveButton_Click(object sender, EventArgs e)
    {
        using (var connection = new MySqlConnection(Literals.GetConnectionString())) {
            connection.Open();

            var commandText = @"
UPDATE usersettings.regionaldata
SET ContactInfo = ?ContactInformation, 
	OperativeInfo = ?Information
WHERE RowId = ?Id;";
            var command     = new MySqlCommand(commandText, connection);
            command.Parameters.AddWithValue("?Id", _regionalSettingsCode);
            command.Parameters.AddWithValue("?ContactInformation", ContactInfoText.Text);
            command.Parameters.AddWithValue("?Information", OperativeInfoText.Text);
            command.ExecuteNonQuery();
            Response.Redirect(String.Format("managep.aspx?cc={0}", _clientCode));
        }
    }
        private void GetData()
        {
            var ruleInfo = @"
SELECT sender.ClassName as Sender, formater.ClassName as Formater, o.RegionCode
FROM ordersendrules.order_send_rules o
	JOIN ordersendrules.order_handlers sender on sender.Id = o.SenderId
	JOIN ordersendrules.order_handlers formater on formater.Id = o.FormaterId
WHERE o.Id = ?RuleId";

            var properties = @"
select hp.*
from ordersendrules.handler_properties hp
where OrderSendRuleId = ?RuleId
order by hp.name;";

            using (var connection = new MySqlConnection(Literals.GetConnectionString())) {
                connection.Open();
                var dataAdapter = new MySqlDataAdapter("", connection);
                dataAdapter.SelectCommand.Parameters.AddWithValue("?RuleId", RuleId);
                Data = new DataSet();

                dataAdapter.SelectCommand.CommandText = properties;
                dataAdapter.Fill(Data, "Properties");

                dataAdapter.SelectCommand.CommandText = ruleInfo;
                dataAdapter.Fill(Data, "RuleInfo");

                if (Data.Tables["RuleInfo"].Rows[0]["RegionCode"] != DBNull.Value)
                {
                    SecurityContext.Administrator.CheckRegion(Convert.ToUInt64(Data.Tables["RuleInfo"].Rows[0]["RegionCode"]));
                }
            }

            Header.Text = String.Format("Настройка свойств для отправщика {0} и форматера {1}",
                                        Data.Tables["RuleInfo"].Rows[0]["Sender"],
                                        Data.Tables["RuleInfo"].Rows[0]["Formater"]);
        }