public void DeleteRefund()
        {
            string        command       = "SP_Delete_Refund_per_Account(@AccountID:Int,@ChannelID:Int,@Month:datetime)";
            SqlConnection sqlConnection = new SqlConnection(AppSettings.Get(string.Empty, "DWH.ConnectionString").ToString());

            sqlConnection.Open();
            MapperUtility.SaveOrRemoveSimpleObject <Refund>(command, System.Data.CommandType.StoredProcedure, SqlOperation.Insert, this, sqlConnection, null);
        }
Esempio n. 2
0
        public void AddRefund()
        {
            string        command       = "SP_Add_Refund_per_Account(@AccountID:Int,@ChannelID:Int,@Month:datetime, @RefundAmount:decimal)";
            SqlConnection sqlConnection = new SqlConnection(AppSettings.GetAbsolute("DWH.ConnectionString").ToString());

            sqlConnection.Open();
            MapperUtility.SaveOrRemoveSimpleObject <Refund>(command, System.Data.CommandType.StoredProcedure, SqlOperation.Insert, this, sqlConnection, null);
        }
        public int UserOperations(SqlOperation sqlOperation)
        {
            SqlTransaction sqlTransaction = null;
            int            returnValue    = -1;

            try
            {
                //Insert/Update/Remove user (also this clean all permissions and assigned groups)
                string        command       = @"User_Operations(@Action:Int,@UserID:Int,@Name:NvarChar,@IsActive:bit,@AccountAdmin:bit,@Email:NvarChar,@Password:NvarChar)";
                SqlConnection sqlConnection = new SqlConnection(DataManager.ConnectionString);
                sqlConnection.Open();
                sqlTransaction = sqlConnection.BeginTransaction("SaveUser");
                returnValue    = this.UserID = Convert.ToInt32(MapperUtility.SaveOrRemoveSimpleObject <User>(command, CommandType.StoredProcedure, sqlOperation, this, sqlConnection, sqlTransaction));

                //insert the new permission
                foreach (KeyValuePair <int, List <AssignedPermission> > assignedPermissionPerAccount in this.AssignedPermissions)
                {
                    foreach (AssignedPermission assignedPermission in assignedPermissionPerAccount.Value)
                    {
                        SqlCommand sqlCommand = DataManager.CreateCommand("Permissions_Operations(@AccountID:Int,@TargetID:Int,@TargetIsGroup:Bit,@PermissionType:NvarChar,@Value:Bit)", CommandType.StoredProcedure);
                        sqlCommand.Connection  = sqlConnection;
                        sqlCommand.Transaction = sqlTransaction;
                        sqlCommand.Parameters["@AccountID"].Value      = assignedPermissionPerAccount.Key;
                        sqlCommand.Parameters["@TargetID"].Value       = this.UserID;
                        sqlCommand.Parameters["@TargetIsGroup"].Value  = 0;
                        sqlCommand.Parameters["@PermissionType"].Value = assignedPermission.PermissionType;
                        sqlCommand.Parameters["@Value"].Value          = assignedPermission.Value;
                        sqlCommand.ExecuteNonQuery();
                    }
                }

                foreach (Group group in this.AssignedToGroups)
                {
                    SqlCommand sqlCommand = DataManager.CreateCommand(@"INSERT INTO User_GUI_UserGroupUser
																	(GroupID,UserID)
																	VALUES
																	(@GroupID:Int,@UserID:Int)"                                                                    );
                    sqlCommand.Parameters["@GroupID"].Value = group.GroupID;
                    sqlCommand.Parameters["@UserID"].Value  = this.UserID;
                    sqlCommand.Connection  = sqlConnection;
                    sqlCommand.Transaction = sqlTransaction;
                    sqlCommand.ExecuteNonQuery();
                }

                sqlTransaction.Commit();
            }
            catch (Exception ex)
            {
                if (sqlTransaction != null)
                {
                    sqlTransaction.Rollback();
                }
                throw ex;
            }
            return(returnValue);
        }
Esempio n. 4
0
        public static void Update(List <CampaignStatusSchedule> campaignStatusSchedules)
        {
            string         command;
            SqlTransaction sqlTransaction = null;
            SqlConnection  sqlConnection  = new SqlConnection(DataManager.ConnectionString);

            sqlConnection.Open();
            sqlTransaction = sqlConnection.BeginTransaction("Schedule");
            command        = "DELETE FROM Campaigns_Scheduling WHERE Campaign_GK=@Campaign_GK:int";
            MapperUtility.SaveOrRemoveSimpleObject <CampaignStatusSchedule>(command, System.Data.CommandType.Text, SqlOperation.Delete, campaignStatusSchedules[0], sqlConnection, sqlTransaction);
            command = @"CampaignStatusSchedule_Insert(@Action:Int,@Account_ID:int,
           @Campaign_GK:int,
           @Channel_ID:int,
           @Day:int,
           @Hour00:int,
           @Hour01:int,
           @Hour02:int,
           @Hour03:int,
           @Hour04:int,
           @Hour05:int,
           @Hour06:int,
           @Hour07:int,
           @Hour08:int,
           @Hour09:int,
           @Hour10:int,
           @Hour11:int,
           @Hour12:int,
           @Hour13:int,
           @Hour14:int,
           @Hour15:int,
           @Hour16:int,
           @Hour17:int,
           @Hour18:int,
           @Hour19:int,
           @Hour20:int,
           @Hour21:int,
           @Hour22:int,
           @Hour23:int)";
            foreach (CampaignStatusSchedule campaignStatusSchedule in campaignStatusSchedules)
            {
                MapperUtility.SaveOrRemoveSimpleObject <CampaignStatusSchedule>(command, System.Data.CommandType.StoredProcedure, SqlOperation.Update, campaignStatusSchedule, sqlConnection, sqlTransaction);
            }
            command = @"UPDATE UserProcess_GUI_PaidCampaign
						SET ScheduleEnabled=@ScheduleEnabled:bit
						WHERE Campaign_GK= @Campaign_GK:int"                        ;
            ;
            MapperUtility.SaveOrRemoveSimpleObject <CampaignStatusSchedule>(command, System.Data.CommandType.Text, SqlOperation.Update, campaignStatusSchedules[0], sqlConnection, sqlTransaction);
            sqlTransaction.Commit();
        }